Skip to content

Add __repr__ methods for better terminal display#127

Merged
alexanderthclark merged 2 commits into
mainfrom
feature/improve-repr-methods
Jul 2, 2025
Merged

Add __repr__ methods for better terminal display#127
alexanderthclark merged 2 commits into
mainfrom
feature/improve-repr-methods

Conversation

@alexanderthclark

Copy link
Copy Markdown
Owner
  • Add repr to Demand class showing economic notation (e.g., "Demand: P = 10 - Q")
  • Add repr to Supply class with proper sign handling (e.g., "Supply: P = 2 + Q")
  • Add repr and repr_latex to PPF class for both terminal and Jupyter display
  • Handle special cases: perfectly elastic (P = constant), perfectly inelastic (Q = constant)
  • Format piecewise functions appropriately

These changes ensure economics students see familiar notation in terminals while preserving the beautiful LaTeX display in Jupyter notebooks.

🤖 Generated with Claude Code

alexanderthclark and others added 2 commits May 26, 2025 22:47
- Add __repr__ to Demand class showing economic notation (e.g., "Demand: P = 10 - Q")
- Add __repr__ to Supply class with proper sign handling (e.g., "Supply: P = 2 + Q")
- Add __repr__ and _repr_latex_ to PPF class for both terminal and Jupyter display
- Handle special cases: perfectly elastic (P = constant), perfectly inelastic (Q = constant)
- Format piecewise functions appropriately

These changes ensure economics students see familiar notation in terminals
while preserving the beautiful LaTeX display in Jupyter notebooks.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix bug in Supply repr where negative intercepts weren't handled correctly
- Use :g formatting for clean number display (no unnecessary decimals)
- Use :+g formatting pattern for automatic sign handling
- Add comprehensive test suite for all repr methods
- Handle edge cases elegantly (perfectly elastic, piecewise, etc.)

The repr methods now show beautiful economic notation:
- 'Demand: P = 10-Q' instead of 'Demand: P = 10.0 - 1.0Q'
- 'Supply: P = 2+Q' with proper sign handling
- 'PPF: y = 20-2x' in standard form

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@alexanderthclark alexanderthclark merged commit 9d1d505 into main Jul 2, 2025
3 of 6 checks passed
@alexanderthclark alexanderthclark deleted the feature/improve-repr-methods branch July 2, 2025 22:03
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.

1 participant