Add __repr__ methods for better terminal display#127
Merged
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These changes ensure economics students see familiar notation in terminals while preserving the beautiful LaTeX display in Jupyter notebooks.
🤖 Generated with Claude Code