Skip to content

Conversation

@JaskRendix
Copy link

PR improves readability, type safety and usability of the esoreader module while preserving backward compatibility.

Key changes include:

  • replaced legacy class definitions with modern Python syntax using type hints (Optional, dict, tuple, list)
  • introduced to_series() method in the EsoFile class to allow direct extraction of a single variable as a pandas Series
  • updated internal logic to handle malformed lines more gracefully during parsing of the data dictionary and data section
  • improved variable filtering in find_variable() to ensure case-insensitive matching and optional key-based filtering
  • enhanced to_frame() method with optional column naming based on either key or variable name
  • added __repr__() methods to DataDictionary and EsoFile classes for easier debugging and logging
  • replaced manual dictionary initialization with dictionary comprehensions for cleaner code
  • consolidated imports and removed unused legacy comments and docstrings where appropriate
  • maintained the original read() function for compatibility, while encouraging use of the newer read_from_path() interface
  • added a test suite using both unittest and pytest, all tests passed before and after the refactor, confirming functional parity. The new to_series() method was excluded from earlier tests but has been validated post-refactor. Note: pytest is included in the separate PR via the pyproject.toml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants