or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/us@3.2.x
tile.json

tessl/pypi-us

tessl install tessl/pypi-us@3.2.0

A package for easily working with US and state metadata

Agent Success

Agent success rate when using this tile

88%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.24x

Baseline

Agent success rate without this tile

71%

task.mdevals/scenario-3/

FIPS Code Validation System

Build a utility that validates and resolves US state FIPS codes from user input.

Requirements

Your system should accept a list of potential FIPS codes (as strings) and return information about their validity and corresponding states.

Core Functionality

Implement a function validate_fips_codes(codes) that:

  • Accepts a list of strings representing potential FIPS codes
  • For each code, determines if it is a valid US state or territory FIPS code
  • Returns a dictionary with the following structure:
    • valid: list of tuples, each containing (fips_code, state_name, state_abbreviation) for valid codes
    • invalid: list of codes that are not valid FIPS codes

Additional Requirements

  • FIPS codes should be validated for both states and territories
  • The function should handle leading zeros (e.g., "01" for Alabama, "06" for California)
  • Invalid codes should be collected and reported
  • State names should be the full official names (e.g., "Alabama", not "AL")

Test Cases

  • Given codes ["01", "06", "24", "99", "invalid"], the function returns valid entries for "01" (Alabama), "06" (California), and "24" (Maryland), and marks "99" and "invalid" as invalid @test

  • Given codes ["78", "72", "00"], the function returns valid entries for "78" (Virgin Islands) and "72" (Puerto Rico), and marks "00" as invalid @test

  • Given an empty list [], the function returns empty lists for both valid and invalid @test

Implementation

@generates

API

def validate_fips_codes(codes):
    """
    Validate a list of FIPS codes and return information about valid states/territories.

    Args:
        codes: List of strings representing potential FIPS codes

    Returns:
        Dictionary with keys:
            - 'valid': List of tuples (fips_code, state_name, abbreviation)
            - 'invalid': List of invalid codes
    """
    pass

Dependencies { .dependencies }

python-us { .dependency }

Provides US state and territory metadata including FIPS code lookup capabilities.