Skip to content

Commit 004be2f

Browse files
committed
2 parents 59eeb2b + 5468710 commit 004be2f

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

eval_protocol/human_id/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ def generate_id(
3939
adjectives = dictionary.adjectives
4040
nouns = dictionary.nouns
4141

42-
# Calculate total combinations: adjectives * nouns * 100 (for 00-99)
43-
total = len(adjectives) * len(nouns) * 100
42+
# Calculate total combinations: adjectives * nouns * 1000000 (for 000000-999999)
43+
total = len(adjectives) * len(nouns) * 1000000
4444

4545
if index >= total:
4646
raise ValueError(f"index out of range. Received {index}, max allowed is {total - 1}")
4747

4848
# Decompose index into adjective, noun, and number
49-
number = index % 100
50-
remaining = index // 100
49+
number = index % 1000000
50+
remaining = index // 1000000
5151
noun_idx = remaining % len(nouns)
5252
adj_idx = remaining // len(nouns)
5353

5454
adjective = adjectives[adj_idx]
5555
noun = nouns[noun_idx]
5656

57-
return f"{adjective}{separator}{noun}{separator}{number:02d}"
57+
return f"{adjective}{separator}{noun}{separator}{number:06d}"
5858

5959
# Random generation
6060
random_obj = system_random
@@ -63,15 +63,15 @@ def generate_id(
6363

6464
adjective = random_obj.choice(dictionary.adjectives)
6565
noun = random_obj.choice(dictionary.nouns)
66-
number = random_obj.randint(0, 99)
66+
number = random_obj.randint(0, 999999)
6767

68-
return f"{adjective}{separator}{noun}{separator}{number:02d}"
68+
return f"{adjective}{separator}{noun}{separator}{number:06d}"
6969

7070

7171
def num_combinations() -> int:
7272
"""
7373
Return the total number of unique IDs possible.
7474
75-
Format uses adjective-noun-NN, so total = adjectives * nouns * 100.
75+
Format uses adjective-noun-NNNNNN, so total = adjectives * nouns * 1000000.
7676
"""
77-
return len(dictionary.adjectives) * len(dictionary.nouns) * 100
77+
return len(dictionary.adjectives) * len(dictionary.nouns) * 1000000

tests/pytest/test_openenv_echo_hub.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010

1111

1212
# Preferred import when using the monolithic `openenv` package
13-
from envs.echo_env import EchoEnv # type: ignore
13+
# Preferred import when using the monolithic `openenv` package
14+
try:
15+
from envs.echo_env import EchoEnv # type: ignore
16+
except ImportError:
17+
# Define dummy class to satisfy OpenEnvRolloutProcessor validation during collection
18+
class EchoEnv: # type: ignore
19+
pass
1420

1521

1622
# Skip these integration-heavy tests on CI runners by default

tests/test_human_id.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@
77
def test_generate_id_basic_format():
88
"""Test that generate_id produces the expected adjective-noun-NN format"""
99
id_str = generate_id(index=0)
10-
# Should match pattern: adjective-noun-NN where NN is 00-99
11-
assert re.match(r"^[a-z]+-[a-z]+-\d{2}$", id_str)
10+
# Should match pattern: adjective-noun-NNNNNN where NNNNNN is 000000-999999
11+
assert re.match(r"^[a-z]+-[a-z]+-\d{6}$", id_str)
1212

1313
# Test a few specific indices to ensure deterministic behavior
14-
assert generate_id(index=0) == "other-time-00"
15-
assert generate_id(index=1) == "other-time-01"
16-
assert generate_id(index=99) == "other-time-99"
17-
assert generate_id(index=100) == "other-year-00"
14+
assert generate_id(index=0) == "other-time-000000"
15+
assert generate_id(index=1) == "other-time-000001"
16+
assert generate_id(index=99) == "other-time-000099"
17+
assert generate_id(index=100) == "other-time-000100"
1818

1919

2020
def test_generate_id_index_mapping():
2121
"""Test that index mapping works correctly"""
2222
# Test number cycling (0-99)
2323
for i in range(100):
2424
id_str = generate_id(index=i)
25-
expected_num = f"{i:02d}"
25+
expected_num = f"{i:06d}"
2626
assert id_str.endswith(f"-{expected_num}")
2727
assert id_str.startswith("other-time-")
2828

29-
# Test noun advancement after 100 numbers
30-
id_100 = generate_id(index=100)
31-
assert id_100.startswith("other-year-00")
29+
# Test noun advancement after 1000000 numbers
30+
id_1000000 = generate_id(index=1000000)
31+
assert id_1000000.startswith("other-year-000000")
3232

33-
# Test adjective advancement (after all nouns * 100)
33+
# Test adjective advancement (after all nouns * 1000000)
3434
# This will depend on dictionary size, so let's test the pattern
3535
from eval_protocol.human_id import dictionary
3636

3737
nouns_count = len(dictionary.nouns)
38-
adjective_boundary = nouns_count * 100
38+
adjective_boundary = nouns_count * 1000000
3939

4040
id_at_boundary = generate_id(index=adjective_boundary)
4141
# Should have advanced to the next adjective
@@ -68,7 +68,7 @@ def test_generate_id_seed_stability():
6868
# Without index, default produces separator '-' and at least 3 components
6969
c = generate_id()
7070

71-
assert re.match(r"^[a-z]+-[a-z]+-\d{2}$", c)
71+
assert re.match(r"^[a-z]+-[a-z]+-\d{6}$", c)
7272

7373

7474
def test_generate_id_seed_with_index():
@@ -83,12 +83,12 @@ def test_generate_id_seed_with_index():
8383
assert x != y
8484

8585
# All should follow the correct format
86-
assert re.match(r"^[a-z]+-[a-z]+-\d{2}$", x)
87-
assert re.match(r"^[a-z]+-[a-z]+-\d{2}$", y)
86+
assert re.match(r"^[a-z]+-[a-z]+-\d{6}$", x)
87+
assert re.match(r"^[a-z]+-[a-z]+-\d{6}$", y)
8888

8989

9090
def test_generate_id_random_format():
9191
"""Test that random generation (no index) produces correct format"""
9292
for _ in range(10):
9393
id_str = generate_id()
94-
assert re.match(r"^[a-z]+-[a-z]+-\d{2}$", id_str)
94+
assert re.match(r"^[a-z]+-[a-z]+-\d{6}$", id_str)

0 commit comments

Comments
 (0)