Skip to content

Fix/horizontal supply curve#123

Merged
alexanderthclark merged 4 commits into
mainfrom
fix/horizontal-supply-curve
May 26, 2025
Merged

Fix/horizontal supply curve#123
alexanderthclark merged 4 commits into
mainfrom
fix/horizontal-supply-curve

Conversation

@alexanderthclark

Copy link
Copy Markdown
Owner

Temporary blockers to prevent errors with perfectly elastic and inelastic curves

alexanderthclark and others added 4 commits May 26, 2025 18:40
- Add custom q() methods to Demand and Supply classes to handle perfectly elastic (horizontal) curves
- Return np.inf at the threshold price with a warning about indeterminacy
- Add warnings when creating horizontal curves to inform users of limitations
- Block perfectly elastic/inelastic curves in Equilibrium constructor
- Add comprehensive unit tests for horizontal curve behavior

This allows horizontal curves to be created without crashing, while clearly
communicating their limitations to users.

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

Co-Authored-By: Claude <noreply@anthropic.com>
…ot economic

- Update warning messages to clarify np.inf is a placeholder for indeterminate quantity
- Update ValueError messages to emphasize this is a software limitation, not economic theory
- Make it clear the economics are valid but the implementation is incomplete

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Use np.isinf() instead of direct equality with np.inf
- Filter out numpy deprecation warnings in warning tests
- Check warning category to avoid false positives

This should fix test failures in Python 3.9 and 3.11 builds.

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

Co-Authored-By: Claude <noreply@anthropic.com>
The root issue was that perfectly elastic curves were calling horizontal_sum(),
which tries to evaluate c.q(price) > 0. When c.q(price) returns an empty array
for horizontal curves, this comparison fails with "truth value of empty array is ambiguous."

Solution: Bypass horizontal_sum entirely for perfectly elastic curves since they
can't be summed anyway (blind_sum explicitly rejects them). Set up minimal
structure for single horizontal elements instead.

This preserves all existing functionality while allowing horizontal curves to be created.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@alexanderthclark alexanderthclark merged commit b997887 into main May 26, 2025
3 of 6 checks passed
@alexanderthclark alexanderthclark deleted the fix/horizontal-supply-curve branch May 26, 2025 23:38
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