glitchlings 0.4.5__cp313-cp313-macosx_11_0_universal2.whl → 0.5.1__cp313-cp313-macosx_11_0_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of glitchlings might be problematic. Click here for more details.
- glitchlings/__init__.py +33 -0
- glitchlings/_zoo_rust.cpython-313-darwin.so +0 -0
- glitchlings/assets/ekkokin_homophones.json +1995 -0
- glitchlings/compat.py +98 -8
- glitchlings/config.py +12 -24
- glitchlings/dev/__init__.py +5 -0
- glitchlings/dev/sync_assets.py +130 -0
- glitchlings/dlc/pytorch_lightning.py +13 -1
- glitchlings/spectroll.py +5 -0
- glitchlings/util/stretchability.py +4 -9
- glitchlings/zoo/__init__.py +10 -2
- glitchlings/zoo/_ocr_confusions.py +3 -3
- glitchlings/zoo/_text_utils.py +10 -9
- glitchlings/zoo/adjax.py +3 -18
- glitchlings/zoo/apostrofae.py +2 -5
- glitchlings/zoo/assets/__init__.py +91 -0
- glitchlings/zoo/ekkokin.py +226 -0
- glitchlings/zoo/jargoyle.py +2 -16
- glitchlings/zoo/mim1c.py +2 -17
- glitchlings/zoo/redactyl.py +3 -17
- glitchlings/zoo/reduple.py +3 -17
- glitchlings/zoo/rushmore.py +3 -20
- glitchlings/zoo/scannequin.py +3 -20
- glitchlings/zoo/spectroll.py +159 -0
- glitchlings/zoo/typogre.py +2 -19
- glitchlings/zoo/zeedub.py +2 -13
- {glitchlings-0.4.5.dist-info → glitchlings-0.5.1.dist-info}/METADATA +22 -7
- glitchlings-0.5.1.dist-info/RECORD +57 -0
- glitchlings/data/__init__.py +0 -1
- glitchlings/zoo/_rate.py +0 -131
- glitchlings-0.4.5.dist-info/RECORD +0 -53
- /glitchlings/{zoo/assets → assets}/apostrofae_pairs.json +0 -0
- /glitchlings/{data → assets}/hokey_assets.json +0 -0
- /glitchlings/{zoo → assets}/ocr_confusions.tsv +0 -0
- {glitchlings-0.4.5.dist-info → glitchlings-0.5.1.dist-info}/WHEEL +0 -0
- {glitchlings-0.4.5.dist-info → glitchlings-0.5.1.dist-info}/entry_points.txt +0 -0
- {glitchlings-0.4.5.dist-info → glitchlings-0.5.1.dist-info}/licenses/LICENSE +0 -0
- {glitchlings-0.4.5.dist-info → glitchlings-0.5.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import random
|
|
4
|
+
import re
|
|
5
|
+
from itertools import zip_longest
|
|
6
|
+
|
|
7
|
+
from .core import AttackOrder, AttackWave, Glitchling
|
|
8
|
+
|
|
9
|
+
_CANONICAL_COLOR_MAP: dict[str, str] = {
|
|
10
|
+
"red": "blue",
|
|
11
|
+
"blue": "red",
|
|
12
|
+
"green": "lime",
|
|
13
|
+
"lime": "green",
|
|
14
|
+
"yellow": "purple",
|
|
15
|
+
"purple": "yellow",
|
|
16
|
+
"orange": "cyan",
|
|
17
|
+
"cyan": "orange",
|
|
18
|
+
"magenta": "teal",
|
|
19
|
+
"teal": "magenta",
|
|
20
|
+
"black": "white",
|
|
21
|
+
"white": "black",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_VALID_MODES = {"literal", "drift"}
|
|
25
|
+
|
|
26
|
+
_COLOR_PATTERN = re.compile(
|
|
27
|
+
r"\b(?P<color>"
|
|
28
|
+
+ "|".join(sorted(_CANONICAL_COLOR_MAP, key=len, reverse=True))
|
|
29
|
+
+ r")(?P<suffix>[a-zA-Z]*)\b",
|
|
30
|
+
re.IGNORECASE,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
_COLOR_ADJACENCY: dict[str, tuple[str, ...]] = {
|
|
34
|
+
"red": ("orange", "magenta", "purple"),
|
|
35
|
+
"blue": ("cyan", "teal", "purple"),
|
|
36
|
+
"green": ("teal", "cyan", "yellow"),
|
|
37
|
+
"lime": ("yellow", "white", "cyan"),
|
|
38
|
+
"yellow": ("orange", "lime", "white"),
|
|
39
|
+
"purple": ("magenta", "red", "blue"),
|
|
40
|
+
"orange": ("red", "yellow", "magenta"),
|
|
41
|
+
"cyan": ("blue", "green", "teal"),
|
|
42
|
+
"magenta": ("purple", "red", "blue"),
|
|
43
|
+
"teal": ("cyan", "green", "blue"),
|
|
44
|
+
"black": ("purple", "blue", "teal"),
|
|
45
|
+
"white": ("yellow", "lime", "cyan"),
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _apply_case(template: str, replacement: str) -> str:
|
|
50
|
+
if not template:
|
|
51
|
+
return replacement
|
|
52
|
+
if template.isupper():
|
|
53
|
+
return replacement.upper()
|
|
54
|
+
if template.islower():
|
|
55
|
+
return replacement.lower()
|
|
56
|
+
if template[0].isupper() and template[1:].islower():
|
|
57
|
+
return replacement.capitalize()
|
|
58
|
+
|
|
59
|
+
characters: list[str] = []
|
|
60
|
+
for repl_char, template_char in zip_longest(replacement, template, fillvalue=""):
|
|
61
|
+
if template_char.isupper():
|
|
62
|
+
characters.append(repl_char.upper())
|
|
63
|
+
elif template_char.islower():
|
|
64
|
+
characters.append(repl_char.lower())
|
|
65
|
+
else:
|
|
66
|
+
characters.append(repl_char)
|
|
67
|
+
return "".join(characters)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _harmonize_suffix(original: str, replacement: str, suffix: str) -> str:
|
|
71
|
+
if not suffix:
|
|
72
|
+
return suffix
|
|
73
|
+
|
|
74
|
+
if (
|
|
75
|
+
original
|
|
76
|
+
and suffix
|
|
77
|
+
and original[-1].lower() == suffix[0].lower()
|
|
78
|
+
and replacement[-1].lower() != suffix[0].lower()
|
|
79
|
+
):
|
|
80
|
+
return suffix[1:]
|
|
81
|
+
return suffix
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _normalize_mode(mode: str | None) -> str:
|
|
85
|
+
normalized = "literal" if mode is None else mode.lower()
|
|
86
|
+
if normalized not in _VALID_MODES:
|
|
87
|
+
valid = ", ".join(sorted(_VALID_MODES))
|
|
88
|
+
raise ValueError(f"Unsupported Spectroll mode '{mode}'. Expected one of: {valid}")
|
|
89
|
+
return normalized
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def swap_colors(
|
|
93
|
+
text: str,
|
|
94
|
+
*,
|
|
95
|
+
seed: int | None = None,
|
|
96
|
+
mode: str = "literal",
|
|
97
|
+
rng: random.Random | None = None,
|
|
98
|
+
) -> str:
|
|
99
|
+
"""Swap canonical colour words for their partners.
|
|
100
|
+
|
|
101
|
+
Examples:
|
|
102
|
+
>>> swap_colors("red green blue")
|
|
103
|
+
'blue lime red'
|
|
104
|
+
>>> swap_colors("red green blue", mode="drift", seed=42)
|
|
105
|
+
'purple teal cyan'
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
normalized_mode = _normalize_mode(mode)
|
|
109
|
+
active_rng = rng if rng is not None else random.Random(seed)
|
|
110
|
+
|
|
111
|
+
def replace(match: re.Match[str]) -> str:
|
|
112
|
+
base = match.group("color")
|
|
113
|
+
suffix = match.group("suffix") or ""
|
|
114
|
+
canonical = base.lower()
|
|
115
|
+
|
|
116
|
+
replacement_base: str | None
|
|
117
|
+
if normalized_mode == "literal":
|
|
118
|
+
replacement_base = _CANONICAL_COLOR_MAP.get(canonical)
|
|
119
|
+
else:
|
|
120
|
+
palette = _COLOR_ADJACENCY.get(canonical)
|
|
121
|
+
if palette:
|
|
122
|
+
replacement_base = active_rng.choice(palette)
|
|
123
|
+
else:
|
|
124
|
+
replacement_base = _CANONICAL_COLOR_MAP.get(canonical)
|
|
125
|
+
|
|
126
|
+
if not replacement_base:
|
|
127
|
+
return match.group(0)
|
|
128
|
+
|
|
129
|
+
suffix_fragment = _harmonize_suffix(base, replacement_base, suffix)
|
|
130
|
+
adjusted = _apply_case(base, replacement_base)
|
|
131
|
+
return f"{adjusted}{suffix_fragment}"
|
|
132
|
+
|
|
133
|
+
return _COLOR_PATTERN.sub(replace, text)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class Spectroll(Glitchling):
|
|
137
|
+
"""Glitchling that remaps colour terms to alternate hues."""
|
|
138
|
+
|
|
139
|
+
def __init__(
|
|
140
|
+
self,
|
|
141
|
+
*,
|
|
142
|
+
mode: str = "literal",
|
|
143
|
+
seed: int | None = None,
|
|
144
|
+
) -> None:
|
|
145
|
+
normalized_mode = _normalize_mode(mode)
|
|
146
|
+
super().__init__(
|
|
147
|
+
name="Spectroll",
|
|
148
|
+
corruption_function=swap_colors,
|
|
149
|
+
scope=AttackWave.WORD,
|
|
150
|
+
order=AttackOrder.NORMAL,
|
|
151
|
+
seed=seed,
|
|
152
|
+
mode=normalized_mode,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
spectroll = Spectroll()
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
__all__ = ["Spectroll", "spectroll", "swap_colors"]
|
glitchlings/zoo/typogre.py
CHANGED
|
@@ -5,7 +5,6 @@ import random
|
|
|
5
5
|
from typing import Any, Optional, cast
|
|
6
6
|
|
|
7
7
|
from ..util import KEYNEIGHBORS
|
|
8
|
-
from ._rate import resolve_rate
|
|
9
8
|
from ._rust_extensions import get_rust_operation
|
|
10
9
|
from .core import AttackOrder, AttackWave, Glitchling
|
|
11
10
|
|
|
@@ -144,16 +143,9 @@ def fatfinger(
|
|
|
144
143
|
keyboard: str = "CURATOR_QWERTY",
|
|
145
144
|
seed: int | None = None,
|
|
146
145
|
rng: random.Random | None = None,
|
|
147
|
-
*,
|
|
148
|
-
max_change_rate: float | None = None,
|
|
149
146
|
) -> str:
|
|
150
147
|
"""Introduce character-level "fat finger" edits with a Rust fast path."""
|
|
151
|
-
effective_rate =
|
|
152
|
-
rate=rate,
|
|
153
|
-
legacy_value=max_change_rate,
|
|
154
|
-
default=0.02,
|
|
155
|
-
legacy_name="max_change_rate",
|
|
156
|
-
)
|
|
148
|
+
effective_rate = 0.02 if rate is None else rate
|
|
157
149
|
|
|
158
150
|
if rng is None:
|
|
159
151
|
rng = random.Random(seed)
|
|
@@ -182,17 +174,10 @@ class Typogre(Glitchling):
|
|
|
182
174
|
self,
|
|
183
175
|
*,
|
|
184
176
|
rate: float | None = None,
|
|
185
|
-
max_change_rate: float | None = None,
|
|
186
177
|
keyboard: str = "CURATOR_QWERTY",
|
|
187
178
|
seed: int | None = None,
|
|
188
179
|
) -> None:
|
|
189
|
-
|
|
190
|
-
effective_rate = resolve_rate(
|
|
191
|
-
rate=rate,
|
|
192
|
-
legacy_value=max_change_rate,
|
|
193
|
-
default=0.02,
|
|
194
|
-
legacy_name="max_change_rate",
|
|
195
|
-
)
|
|
180
|
+
effective_rate = 0.02 if rate is None else rate
|
|
196
181
|
super().__init__(
|
|
197
182
|
name="Typogre",
|
|
198
183
|
corruption_function=fatfinger,
|
|
@@ -205,8 +190,6 @@ class Typogre(Glitchling):
|
|
|
205
190
|
|
|
206
191
|
def pipeline_operation(self) -> dict[str, Any] | None:
|
|
207
192
|
rate = self.kwargs.get("rate")
|
|
208
|
-
if rate is None:
|
|
209
|
-
rate = self.kwargs.get("max_change_rate")
|
|
210
193
|
if rate is None:
|
|
211
194
|
return None
|
|
212
195
|
|
glitchlings/zoo/zeedub.py
CHANGED
|
@@ -5,7 +5,6 @@ import random
|
|
|
5
5
|
from collections.abc import Sequence
|
|
6
6
|
from typing import Any, cast
|
|
7
7
|
|
|
8
|
-
from ._rate import resolve_rate
|
|
9
8
|
from ._rust_extensions import get_rust_operation
|
|
10
9
|
from .core import AttackOrder, AttackWave, Glitchling
|
|
11
10
|
|
|
@@ -77,12 +76,7 @@ def insert_zero_widths(
|
|
|
77
76
|
characters: Sequence[str] | None = None,
|
|
78
77
|
) -> str:
|
|
79
78
|
"""Inject zero-width characters between non-space character pairs."""
|
|
80
|
-
effective_rate =
|
|
81
|
-
rate=rate,
|
|
82
|
-
legacy_value=None,
|
|
83
|
-
default=0.02,
|
|
84
|
-
legacy_name="rate",
|
|
85
|
-
)
|
|
79
|
+
effective_rate = 0.02 if rate is None else rate
|
|
86
80
|
|
|
87
81
|
if rng is None:
|
|
88
82
|
rng = random.Random(seed)
|
|
@@ -142,12 +136,7 @@ class Zeedub(Glitchling):
|
|
|
142
136
|
seed: int | None = None,
|
|
143
137
|
characters: Sequence[str] | None = None,
|
|
144
138
|
) -> None:
|
|
145
|
-
effective_rate =
|
|
146
|
-
rate=rate,
|
|
147
|
-
legacy_value=None,
|
|
148
|
-
default=0.02,
|
|
149
|
-
legacy_name="rate",
|
|
150
|
-
)
|
|
139
|
+
effective_rate = 0.02 if rate is None else rate
|
|
151
140
|
super().__init__(
|
|
152
141
|
name="Zeedub",
|
|
153
142
|
corruption_function=insert_zero_widths,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: glitchlings
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: Monsters for your language games.
|
|
5
5
|
Author: osoleve
|
|
6
6
|
License: Apache License
|
|
@@ -294,11 +294,14 @@ Dynamic: license-file
|
|
|
294
294
|
Every language game breeds monsters.
|
|
295
295
|
```
|
|
296
296
|
|
|
297
|
+

|
|
297
298
|
[](https://pypi.org/project/glitchlings/)
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+

|
|
300
|
+

|
|
301
|
+

|
|
302
|
+

|
|
303
|
+

|
|
304
|
+

|
|
302
305
|
|
|
303
306
|
`Glitchlings` are **utilities for corrupting the text inputs to your language models in deterministic, _linguistically principled_** ways.
|
|
304
307
|
Each embodies a different way that documents can be compromised in the wild.
|
|
@@ -390,11 +393,13 @@ glitchlings --list
|
|
|
390
393
|
Apostrofae — scope: Character, order: normal
|
|
391
394
|
Hokey — scope: Character, order: first
|
|
392
395
|
Mim1c — scope: Character, order: last
|
|
396
|
+
Ekkokin — scope: Word, order: early
|
|
393
397
|
Jargoyle — scope: Word, order: normal
|
|
394
398
|
Adjax — scope: Word, order: normal
|
|
395
399
|
Reduple — scope: Word, order: normal
|
|
396
400
|
Rushmore — scope: Word, order: normal
|
|
397
401
|
Redactyl — scope: Word, order: normal
|
|
402
|
+
Spectroll — scope: Word, order: normal
|
|
398
403
|
Scannequin — scope: Character, order: late
|
|
399
404
|
Zeedub — scope: Character, order: last
|
|
400
405
|
```
|
|
@@ -549,6 +554,18 @@ _Watch your step around here._
|
|
|
549
554
|
> - `characters (Sequence[str])`: Optional override for the pool of zero-width strings to inject (default: curated invisibles such as U+200B, U+200C, U+200D, U+FEFF, U+2060).
|
|
550
555
|
> - `seed (int)`: The random seed for reproducibility (default: 151).
|
|
551
556
|
|
|
557
|
+
### Ekkokin
|
|
558
|
+
|
|
559
|
+
_Did you hear what I heard?_
|
|
560
|
+
|
|
561
|
+
> _**Echo Chamber.**_ Ekkokin swaps words with curated homophones so the text still sounds right while the spelling drifts. Groups are normalised to prevent duplicates and casing is preserved when substitutions fire.
|
|
562
|
+
>
|
|
563
|
+
> Args
|
|
564
|
+
>
|
|
565
|
+
> - `rate (float)`: Maximum proportion of eligible words to replace with homophones (default: 0.02, 2%).
|
|
566
|
+
> - `weighting (str)`: Sampling strategy applied within each homophone set (default: "flat").
|
|
567
|
+
> - `seed (int)`: The random seed for reproducibility (default: 151).
|
|
568
|
+
|
|
552
569
|
### Jargoyle
|
|
553
570
|
|
|
554
571
|
_Uh oh. The worst person you know just bought a thesaurus._
|
|
@@ -596,7 +613,6 @@ _Keep your hands and punctuation where I can see them._
|
|
|
596
613
|
> Args
|
|
597
614
|
>
|
|
598
615
|
> - `rate (float)`: Probability that each adjacent pair swaps cores (default: 0.5, 50%).
|
|
599
|
-
> - `swap_rate (float)`: Alias for `rate`, retained for backward compatibility.
|
|
600
616
|
> - `seed (int)`: The random seed for reproducibility (default: 151).
|
|
601
617
|
|
|
602
618
|
### Redactyl
|
|
@@ -617,7 +633,6 @@ _Oops, that was my black highlighter._
|
|
|
617
633
|
|
|
618
634
|
### _Containment procedures pending_
|
|
619
635
|
|
|
620
|
-
- `ekkokin` substitutes words with homophones (phonetic equivalents).
|
|
621
636
|
- `nylingual` backtranslates portions of text.
|
|
622
637
|
- `glothopper` introduces code-switching effects, blending languages or dialects.
|
|
623
638
|
- `palimpsest` rewrites, but leaves accidental traces of the past.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
glitchlings/__init__.py,sha256=pDqhE33ZkTz8xzvVjc1FsSOYRBPdgaSL1es9e0v31Uc,1947
|
|
2
|
+
glitchlings/__main__.py,sha256=f-P4jiVBd7ZpS6QxRpa_6SJgOG03UhZhcWasMDRWLs8,120
|
|
3
|
+
glitchlings/_zoo_rust.cpython-313-darwin.so,sha256=IeIxP7owt7LbN0ksQFM899v3JccqxfoXJ5DqdbJJpPI,2753200
|
|
4
|
+
glitchlings/compat.py,sha256=_iUEErikfkgPOik1zymPCU4-Pbyt-6h5fWoF7viohXs,12065
|
|
5
|
+
glitchlings/config.py,sha256=xqTc2YJGMYJHbnh1nxQBdCKhQ6sqcjWJViArjarsZa4,12303
|
|
6
|
+
glitchlings/config.toml,sha256=04-Y_JCdQU68SRmwk2qZqrH_bbX4jEH9uh7URtxdIHA,99
|
|
7
|
+
glitchlings/main.py,sha256=uw8VbDgxov1m-wYHPDl2dP5ItpLB4ZHpb0ChJXzcL0o,10623
|
|
8
|
+
glitchlings/spectroll.py,sha256=m5FRDYa-MjPfh29Zpk9bDmL6xPKOXS-kysFFz9WOTkE,150
|
|
9
|
+
glitchlings/assets/apostrofae_pairs.json,sha256=bfjSEaMTI_axGNJ93nI431KXU0IVp7ayO42gGcMgL6U,521
|
|
10
|
+
glitchlings/assets/ekkokin_homophones.json,sha256=TAvwBojTpWc-jk6jQjVDGMbHLfsjZLBPe7f78mkNLF0,17059
|
|
11
|
+
glitchlings/assets/hokey_assets.json,sha256=9drpOv_PHHxs7jZOcgMr9G-Nswx_UuMzC4yQ0O8mIZ0,2890
|
|
12
|
+
glitchlings/assets/ocr_confusions.tsv,sha256=KhtR7vJDTITpfTSGa-I7RHr6CK7LkGi2KjdhEWipI6o,183
|
|
13
|
+
glitchlings/dev/__init__.py,sha256=v-qk9iE6b7VEg-4bpKH2PAifG-rkrCRgrS0C4VPR7ow,142
|
|
14
|
+
glitchlings/dev/sync_assets.py,sha256=xtco1x9tZFfVLajronYs8Iv0_43DU7ZTrD-sRR74b88,3675
|
|
15
|
+
glitchlings/dlc/__init__.py,sha256=qlY4nuagy4AAWuPMwmuhwK2m36ktp-qkeiIxC7OXg34,305
|
|
16
|
+
glitchlings/dlc/_shared.py,sha256=moQwnJdHMo-dx5uK0zM8XdPy5cs-OlAzYKVWfUP0RSQ,4407
|
|
17
|
+
glitchlings/dlc/huggingface.py,sha256=BWceVUm28Yd8b7Tf_lmnPGgSVN1hZEmseRjf17nAPJw,2576
|
|
18
|
+
glitchlings/dlc/prime.py,sha256=zhm0oTVKNDa1ByxZTP42rmMVaJDyx77w2g6NHy4jndc,8607
|
|
19
|
+
glitchlings/dlc/pytorch.py,sha256=Laqz5o0UZXE1X9P-Qxb6KE0D5lcBKAoBbKsn-fnd6c0,6233
|
|
20
|
+
glitchlings/dlc/pytorch_lightning.py,sha256=BcxH6WHCl2SpDje7WuTN9V04KKfTqhaXFb2UzajNr4Y,8478
|
|
21
|
+
glitchlings/lexicon/__init__.py,sha256=ooEPcAJhCI2Nw5z8OsQ0EtVpKBfiTrU0-AQJq8Zn2nQ,6007
|
|
22
|
+
glitchlings/lexicon/_cache.py,sha256=oWdQtiU3csUAs-fYJRHuS_314j8JJ-T8AL73-GxVXzA,4072
|
|
23
|
+
glitchlings/lexicon/metrics.py,sha256=VBFfFpxjiEwZtK-jS55H8xP7MTC_0OjY8lQ5zSQ9aTY,4572
|
|
24
|
+
glitchlings/lexicon/vector.py,sha256=hUtMewkdLdMscQWjFgWcspSg0C_C0JdhFSMAs0HA-i0,22600
|
|
25
|
+
glitchlings/lexicon/wordnet.py,sha256=8wEN3XHI8Cf01h4h9cP4F25FLlGIoUrvk5l2nsgkfx4,7576
|
|
26
|
+
glitchlings/lexicon/data/default_vector_cache.json,sha256=3iVH0nX8EqMbqOkKWvORCGYtN0LKHn5G_Snlizsnm1g,997
|
|
27
|
+
glitchlings/util/__init__.py,sha256=vc3EAY8ehRjbOiryFdaqvvljXcyNGtZSPiEp9ok1vVw,4674
|
|
28
|
+
glitchlings/util/adapters.py,sha256=psxQFYSFmh1u7NuqtIrKwQP5FOhOrZoxZzc7X7DDi9U,693
|
|
29
|
+
glitchlings/util/hokey_generator.py,sha256=NCbOGw55SG720VYnuwEdFAfdOvYlmjsZ0hAr5Y0Ja0Y,4483
|
|
30
|
+
glitchlings/util/stretch_locator.py,sha256=INTMz7PXe-0HoDaMnQIQxJ266nABMXBYD67oJM8ur8g,4194
|
|
31
|
+
glitchlings/util/stretchability.py,sha256=Rs-OHlfhRxGFlZeEQgEN66Z_CYTcWJrGypu7X5Yc9i4,12667
|
|
32
|
+
glitchlings/zoo/__init__.py,sha256=MU2GLhBQ64I_T8rcozVFK6LWNzF4pAbdi5BIK92Uqrw,5579
|
|
33
|
+
glitchlings/zoo/_ocr_confusions.py,sha256=0Y2GvfXCUIrXggL-tsFMQqzEFYVp6p5r7F-4dGrXiT4,1139
|
|
34
|
+
glitchlings/zoo/_rust_extensions.py,sha256=Bsd0kiPB1rUn5x3k7ykydFuk2YSvXS9CQGPRlE5XzXY,4211
|
|
35
|
+
glitchlings/zoo/_sampling.py,sha256=KrWyUSsYXghlvktS5hQBO0bPqywEEyA49A2qDWInB7Q,1586
|
|
36
|
+
glitchlings/zoo/_text_utils.py,sha256=NG9Iru9k3oSCxwYFAbvY4iG5NzHRYOIEtUXtvhKe4wA,2771
|
|
37
|
+
glitchlings/zoo/adjax.py,sha256=D3gadataEL7QzxrTOElwNdXHKrJmb2EB9qwNLbTVUK0,3136
|
|
38
|
+
glitchlings/zoo/apostrofae.py,sha256=zfQrq_ds0N6CTdqz3zsDO4KfiVLb5gx-0S4_VU19vMM,3674
|
|
39
|
+
glitchlings/zoo/core.py,sha256=dRzUTmhOswDV0hWcaD-Sx7rZdPlrszn7C_1G2xd4ECk,20675
|
|
40
|
+
glitchlings/zoo/ekkokin.py,sha256=jLMndJCIeoeb6fnFbVEf3FAav5FpWM6nkAXsqys56Ms,6442
|
|
41
|
+
glitchlings/zoo/hokey.py,sha256=71z1JGzKGb_N8Wo7LVuS7qAqH2T0Y0h2LemIw66eprs,5298
|
|
42
|
+
glitchlings/zoo/jargoyle.py,sha256=dkJpcDwBqyNJpsJDk3k1hAkLpLXKu0fH0ZJyhhllHWI,11260
|
|
43
|
+
glitchlings/zoo/mim1c.py,sha256=BQ0kR-ob5TK5BrysipTUx1Yox6G5wlYi-EBH2V93xmI,3011
|
|
44
|
+
glitchlings/zoo/redactyl.py,sha256=lmFb3dobXpsQfwmgT-9yhoKIvrJyilu_yhj4mef0cm0,5144
|
|
45
|
+
glitchlings/zoo/reduple.py,sha256=uawpaq5cDBdGGbw0CwdITYp56nI6fazCTr9QIrJb0ag,3777
|
|
46
|
+
glitchlings/zoo/rushmore.py,sha256=jsffZAfhpDTIUtG-jjBzM7bZUCnz2truR0fNNkpVR3M,3759
|
|
47
|
+
glitchlings/zoo/scannequin.py,sha256=oaBiqU57dLruCPHo-W2ojno3lolefSAcvTjXpFwLarM,4406
|
|
48
|
+
glitchlings/zoo/spectroll.py,sha256=WrXkZo8saXTPL_2pBCi5K-7UmXXhTR42em5IvjrJPCQ,4476
|
|
49
|
+
glitchlings/zoo/typogre.py,sha256=NqA9b3HmFl8hR6bVLe85Tjv6uEYoDoSkb0i9gnd8t2Y,6188
|
|
50
|
+
glitchlings/zoo/zeedub.py,sha256=Smegw7zUBAiMapKwZUqP0MqBKSCN5RNXvpbpU_ypnfI,4618
|
|
51
|
+
glitchlings/zoo/assets/__init__.py,sha256=0OLRgQvfwYeRVMQTUOAFDiOnRZPgVFnmaZj2KE-AL_I,2729
|
|
52
|
+
glitchlings-0.5.1.dist-info/licenses/LICENSE,sha256=YCvGip-LoaRyu6h0nPo71q6eHEkzUpsE11psDJOIRkw,11337
|
|
53
|
+
glitchlings-0.5.1.dist-info/METADATA,sha256=wGG7OKTnMBFU4SBqIxOr8csj6nZqxY6H5GPL_2C76xk,33917
|
|
54
|
+
glitchlings-0.5.1.dist-info/WHEEL,sha256=3s_eT7rbkGQeiKRiW_YCG21vqO2C4rGI4Jg-le1fLJ0,114
|
|
55
|
+
glitchlings-0.5.1.dist-info/entry_points.txt,sha256=kGOwuAsjFDLtztLisaXtOouq9wFVMOJg5FzaAkg-Hto,54
|
|
56
|
+
glitchlings-0.5.1.dist-info/top_level.txt,sha256=VHFNBrLjtDwPCYXbGKi6o17Eueedi81eNbR3hBOoST0,12
|
|
57
|
+
glitchlings-0.5.1.dist-info/RECORD,,
|
glitchlings/data/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"""Static data assets shared across Glitchlings implementations."""
|
glitchlings/zoo/_rate.py
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"""Utilities for handling legacy parameter names across glitchling classes."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import warnings
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def resolve_rate(
|
|
9
|
-
*,
|
|
10
|
-
rate: float | None,
|
|
11
|
-
legacy_value: float | None,
|
|
12
|
-
default: float,
|
|
13
|
-
legacy_name: str,
|
|
14
|
-
) -> float:
|
|
15
|
-
"""Return the effective rate while enforcing mutual exclusivity.
|
|
16
|
-
|
|
17
|
-
This function centralizes the handling of legacy parameter names, allowing
|
|
18
|
-
glitchlings to maintain backwards compatibility while encouraging migration
|
|
19
|
-
to the standardized 'rate' parameter.
|
|
20
|
-
|
|
21
|
-
Parameters
|
|
22
|
-
----------
|
|
23
|
-
rate : float | None
|
|
24
|
-
The preferred parameter value.
|
|
25
|
-
legacy_value : float | None
|
|
26
|
-
The deprecated legacy parameter value.
|
|
27
|
-
default : float
|
|
28
|
-
Default value if neither parameter is specified.
|
|
29
|
-
legacy_name : str
|
|
30
|
-
Name of the legacy parameter for error/warning messages.
|
|
31
|
-
|
|
32
|
-
Returns
|
|
33
|
-
-------
|
|
34
|
-
float
|
|
35
|
-
The resolved rate value.
|
|
36
|
-
|
|
37
|
-
Raises
|
|
38
|
-
------
|
|
39
|
-
ValueError
|
|
40
|
-
If both rate and legacy_value are specified simultaneously.
|
|
41
|
-
|
|
42
|
-
Warnings
|
|
43
|
-
--------
|
|
44
|
-
DeprecationWarning
|
|
45
|
-
If the legacy parameter is used, a deprecation warning is issued.
|
|
46
|
-
|
|
47
|
-
Examples
|
|
48
|
-
--------
|
|
49
|
-
>>> resolve_rate(rate=0.5, legacy_value=None, default=0.1, legacy_name="old_rate")
|
|
50
|
-
0.5
|
|
51
|
-
>>> resolve_rate(rate=None, legacy_value=0.3, default=0.1, legacy_name="old_rate")
|
|
52
|
-
0.3 # Issues deprecation warning
|
|
53
|
-
>>> resolve_rate(rate=None, legacy_value=None, default=0.1, legacy_name="old_rate")
|
|
54
|
-
0.1
|
|
55
|
-
|
|
56
|
-
"""
|
|
57
|
-
if rate is not None and legacy_value is not None:
|
|
58
|
-
raise ValueError(f"Specify either 'rate' or '{legacy_name}', not both.")
|
|
59
|
-
|
|
60
|
-
if rate is not None:
|
|
61
|
-
return rate
|
|
62
|
-
|
|
63
|
-
if legacy_value is not None:
|
|
64
|
-
warnings.warn(
|
|
65
|
-
f"The '{legacy_name}' parameter is deprecated and will be removed in version 0.6.0. "
|
|
66
|
-
f"Use 'rate' instead.",
|
|
67
|
-
DeprecationWarning,
|
|
68
|
-
stacklevel=3,
|
|
69
|
-
)
|
|
70
|
-
return legacy_value
|
|
71
|
-
|
|
72
|
-
return default
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def resolve_legacy_param(
|
|
76
|
-
*,
|
|
77
|
-
preferred_value: object,
|
|
78
|
-
legacy_value: object,
|
|
79
|
-
default: object,
|
|
80
|
-
preferred_name: str,
|
|
81
|
-
legacy_name: str,
|
|
82
|
-
) -> object:
|
|
83
|
-
"""Resolve a parameter that has both preferred and legacy names.
|
|
84
|
-
|
|
85
|
-
This is a generalized version of resolve_rate() that works with any type.
|
|
86
|
-
|
|
87
|
-
Parameters
|
|
88
|
-
----------
|
|
89
|
-
preferred_value : object
|
|
90
|
-
The value from the preferred parameter name.
|
|
91
|
-
legacy_value : object
|
|
92
|
-
The value from the legacy parameter name.
|
|
93
|
-
default : object
|
|
94
|
-
Default value if neither parameter is specified.
|
|
95
|
-
preferred_name : str
|
|
96
|
-
Name of the preferred parameter.
|
|
97
|
-
legacy_name : str
|
|
98
|
-
Name of the legacy parameter for warning messages.
|
|
99
|
-
|
|
100
|
-
Returns
|
|
101
|
-
-------
|
|
102
|
-
object
|
|
103
|
-
The resolved parameter value.
|
|
104
|
-
|
|
105
|
-
Raises
|
|
106
|
-
------
|
|
107
|
-
ValueError
|
|
108
|
-
If both preferred and legacy values are specified simultaneously.
|
|
109
|
-
|
|
110
|
-
Warnings
|
|
111
|
-
--------
|
|
112
|
-
DeprecationWarning
|
|
113
|
-
If the legacy parameter is used.
|
|
114
|
-
|
|
115
|
-
"""
|
|
116
|
-
if preferred_value is not None and legacy_value is not None:
|
|
117
|
-
raise ValueError(f"Specify either '{preferred_name}' or '{legacy_name}', not both.")
|
|
118
|
-
|
|
119
|
-
if preferred_value is not None:
|
|
120
|
-
return preferred_value
|
|
121
|
-
|
|
122
|
-
if legacy_value is not None:
|
|
123
|
-
warnings.warn(
|
|
124
|
-
f"The '{legacy_name}' parameter is deprecated and will be removed in version 0.6.0. "
|
|
125
|
-
f"Use '{preferred_name}' instead.",
|
|
126
|
-
DeprecationWarning,
|
|
127
|
-
stacklevel=3,
|
|
128
|
-
)
|
|
129
|
-
return legacy_value
|
|
130
|
-
|
|
131
|
-
return default
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
glitchlings/__init__.py,sha256=A6m-sj1Gnq5DXdaD7IRsPnMvXW9UjZh3fQGcvps22uw,1230
|
|
2
|
-
glitchlings/__main__.py,sha256=f-P4jiVBd7ZpS6QxRpa_6SJgOG03UhZhcWasMDRWLs8,120
|
|
3
|
-
glitchlings/_zoo_rust.cpython-313-darwin.so,sha256=1r9-InXhPIMfF5aQu5uiphWat3qF0LswlN_rwrjrCe8,2697808
|
|
4
|
-
glitchlings/compat.py,sha256=lswR7J3kXER5hPXeyfkO-7USJvUhdtTi1ovJgEpspKc,8892
|
|
5
|
-
glitchlings/config.py,sha256=J_Bk901-WLeqDhrmvTrjUZLxgIgSqR0qYU2oDaNPjt8,12937
|
|
6
|
-
glitchlings/config.toml,sha256=04-Y_JCdQU68SRmwk2qZqrH_bbX4jEH9uh7URtxdIHA,99
|
|
7
|
-
glitchlings/main.py,sha256=uw8VbDgxov1m-wYHPDl2dP5ItpLB4ZHpb0ChJXzcL0o,10623
|
|
8
|
-
glitchlings/data/__init__.py,sha256=JZwsJhnZHnr2onnukNduNjfNSurzGn3v7r1flq_3yl4,68
|
|
9
|
-
glitchlings/data/hokey_assets.json,sha256=9drpOv_PHHxs7jZOcgMr9G-Nswx_UuMzC4yQ0O8mIZ0,2890
|
|
10
|
-
glitchlings/dlc/__init__.py,sha256=qlY4nuagy4AAWuPMwmuhwK2m36ktp-qkeiIxC7OXg34,305
|
|
11
|
-
glitchlings/dlc/_shared.py,sha256=moQwnJdHMo-dx5uK0zM8XdPy5cs-OlAzYKVWfUP0RSQ,4407
|
|
12
|
-
glitchlings/dlc/huggingface.py,sha256=BWceVUm28Yd8b7Tf_lmnPGgSVN1hZEmseRjf17nAPJw,2576
|
|
13
|
-
glitchlings/dlc/prime.py,sha256=zhm0oTVKNDa1ByxZTP42rmMVaJDyx77w2g6NHy4jndc,8607
|
|
14
|
-
glitchlings/dlc/pytorch.py,sha256=Laqz5o0UZXE1X9P-Qxb6KE0D5lcBKAoBbKsn-fnd6c0,6233
|
|
15
|
-
glitchlings/dlc/pytorch_lightning.py,sha256=rhDwRgOGVzaEet27QG8GigKh6hK5ZdTBOxGE2G0MPxw,8005
|
|
16
|
-
glitchlings/lexicon/__init__.py,sha256=ooEPcAJhCI2Nw5z8OsQ0EtVpKBfiTrU0-AQJq8Zn2nQ,6007
|
|
17
|
-
glitchlings/lexicon/_cache.py,sha256=oWdQtiU3csUAs-fYJRHuS_314j8JJ-T8AL73-GxVXzA,4072
|
|
18
|
-
glitchlings/lexicon/metrics.py,sha256=VBFfFpxjiEwZtK-jS55H8xP7MTC_0OjY8lQ5zSQ9aTY,4572
|
|
19
|
-
glitchlings/lexicon/vector.py,sha256=hUtMewkdLdMscQWjFgWcspSg0C_C0JdhFSMAs0HA-i0,22600
|
|
20
|
-
glitchlings/lexicon/wordnet.py,sha256=8wEN3XHI8Cf01h4h9cP4F25FLlGIoUrvk5l2nsgkfx4,7576
|
|
21
|
-
glitchlings/lexicon/data/default_vector_cache.json,sha256=3iVH0nX8EqMbqOkKWvORCGYtN0LKHn5G_Snlizsnm1g,997
|
|
22
|
-
glitchlings/util/__init__.py,sha256=vc3EAY8ehRjbOiryFdaqvvljXcyNGtZSPiEp9ok1vVw,4674
|
|
23
|
-
glitchlings/util/adapters.py,sha256=psxQFYSFmh1u7NuqtIrKwQP5FOhOrZoxZzc7X7DDi9U,693
|
|
24
|
-
glitchlings/util/hokey_generator.py,sha256=NCbOGw55SG720VYnuwEdFAfdOvYlmjsZ0hAr5Y0Ja0Y,4483
|
|
25
|
-
glitchlings/util/stretch_locator.py,sha256=INTMz7PXe-0HoDaMnQIQxJ266nABMXBYD67oJM8ur8g,4194
|
|
26
|
-
glitchlings/util/stretchability.py,sha256=W_FC1-6x1LICLjEyv5rqpsnKnBcj6Lhc5u5A_5cWWIM,12819
|
|
27
|
-
glitchlings/zoo/__init__.py,sha256=xCVVAHLJ4lxl1JQUzff9fr84pJbB04fyXBjuX1m3YSw,5339
|
|
28
|
-
glitchlings/zoo/_ocr_confusions.py,sha256=Ju2_avXiwsr1p8zWFUTOzMxJ8vT5PpYobuGIn4L_sqI,1204
|
|
29
|
-
glitchlings/zoo/_rate.py,sha256=tkIlXHewE8s9w1jpCw8ZzkVN31690FAnvTM_R3dCIpY,3579
|
|
30
|
-
glitchlings/zoo/_rust_extensions.py,sha256=Bsd0kiPB1rUn5x3k7ykydFuk2YSvXS9CQGPRlE5XzXY,4211
|
|
31
|
-
glitchlings/zoo/_sampling.py,sha256=KrWyUSsYXghlvktS5hQBO0bPqywEEyA49A2qDWInB7Q,1586
|
|
32
|
-
glitchlings/zoo/_text_utils.py,sha256=fS5L_eq-foBbBdiv4ymI8-O0D0csc3yDekHpX8bqfV4,2754
|
|
33
|
-
glitchlings/zoo/adjax.py,sha256=XT5kKqPOUPgKSDOcR__HBnv4OXtBKee40GuNNmm1GYI,3518
|
|
34
|
-
glitchlings/zoo/apostrofae.py,sha256=qjpfnxdPWXMNzZnSD7UMfvHyzGKa7TLsvUhMsIvjwj8,3822
|
|
35
|
-
glitchlings/zoo/core.py,sha256=dRzUTmhOswDV0hWcaD-Sx7rZdPlrszn7C_1G2xd4ECk,20675
|
|
36
|
-
glitchlings/zoo/hokey.py,sha256=71z1JGzKGb_N8Wo7LVuS7qAqH2T0Y0h2LemIw66eprs,5298
|
|
37
|
-
glitchlings/zoo/jargoyle.py,sha256=2TGU_z8gILwQ-lyZEqvmsrLupxqb8ydlDiwcp-O6WwY,11679
|
|
38
|
-
glitchlings/zoo/mim1c.py,sha256=-fgodKWZq--Xw8L2t1EqNbsh48bwX5jZxmiXdoaQShI,3437
|
|
39
|
-
glitchlings/zoo/ocr_confusions.tsv,sha256=KhtR7vJDTITpfTSGa-I7RHr6CK7LkGi2KjdhEWipI6o,183
|
|
40
|
-
glitchlings/zoo/redactyl.py,sha256=eWn7JC81BXkp2bSinwrBfU3jXukcUGDVkaa6BcGvte4,5559
|
|
41
|
-
glitchlings/zoo/reduple.py,sha256=zSc1N_-tz9Kl7CDMrdZKgCuW3Bxp_-g6axadAa6AszM,4224
|
|
42
|
-
glitchlings/zoo/rushmore.py,sha256=k429trwNPcWJHEOIoeGsdKBzJNL4Fxz9KRqX3Ro9u_0,4286
|
|
43
|
-
glitchlings/zoo/scannequin.py,sha256=GfjLYWWp-jdnOBmdg7gt5wQnobY8jWQHScB5EMgo6HE,4870
|
|
44
|
-
glitchlings/zoo/typogre.py,sha256=BQotNL-gn4PXQI9j63d2w9mQ4X6ZJKSJ4de-GN-gmUI,6686
|
|
45
|
-
glitchlings/zoo/zeedub.py,sha256=aNnjZGeTmMqA2WjgtGh7Fgl9pUQo3AZ2B-tYs2ZFOQE,4840
|
|
46
|
-
glitchlings/zoo/assets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
|
-
glitchlings/zoo/assets/apostrofae_pairs.json,sha256=bfjSEaMTI_axGNJ93nI431KXU0IVp7ayO42gGcMgL6U,521
|
|
48
|
-
glitchlings-0.4.5.dist-info/licenses/LICENSE,sha256=YCvGip-LoaRyu6h0nPo71q6eHEkzUpsE11psDJOIRkw,11337
|
|
49
|
-
glitchlings-0.4.5.dist-info/METADATA,sha256=3h0Eb8nUL3NXb67OQBYEnuL-aNs0oJ8-dLVAQDeFfD8,33498
|
|
50
|
-
glitchlings-0.4.5.dist-info/WHEEL,sha256=3s_eT7rbkGQeiKRiW_YCG21vqO2C4rGI4Jg-le1fLJ0,114
|
|
51
|
-
glitchlings-0.4.5.dist-info/entry_points.txt,sha256=kGOwuAsjFDLtztLisaXtOouq9wFVMOJg5FzaAkg-Hto,54
|
|
52
|
-
glitchlings-0.4.5.dist-info/top_level.txt,sha256=VHFNBrLjtDwPCYXbGKi6o17Eueedi81eNbR3hBOoST0,12
|
|
53
|
-
glitchlings-0.4.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|