Principles of Economics toolkit for demand/supply analytics and diagrams.
Project description
principle-econ
principle-econ is a Python package for Principles of Economics market analysis and diagrams.
It focuses on linear demand/supply models with clean module boundaries across solver logic, policy layers, welfare decomposition, and plotting.
Features
- Solve market equilibrium from two linear equations
- Comparative statics with direction metadata
- Tax analysis: fixed, per-unit, ad valorem, and legal incidence side
- Price controls: ceiling/floor with shortage/surplus
- Welfare decomposition: CS, PS, tax revenue, TS, DWL
- Renderer-friendly polygon outputs and labeled welfare regions
- CLI workflows with JSON output
- Example figures generated in monochrome style for teaching slides
Installation
pip install principle-econ
For development:
git clone https://github.com/EconViz/principle-econ.git
cd principle-econ
poetry install --with dev
Quick Start
from principle_econ.core.line import Line
from principle_econ.core.equilibrium import solve_equilibrium
from principle_econ.plot.figure import MarketFigure
demand = Line.from_inverse(10.0, -1.0)
supply = Line.from_inverse(2.0, 1.0)
eq = solve_equilibrium(demand, supply)
fig = MarketFigure(x_max=12, y_max=12, title="Basic Equilibrium", palette="monochrome")
fig.add_curves(demand, supply, q_max=10)
fig.add_equilibrium(eq)
fig.finalize()
fig.save("basic_equilibrium.png")
fig.close()
Tax Example (Consumer vs Producer Incidence)
from principle_econ.core.line import Line
from principle_econ.plot.figure import MarketFigure
from principle_econ.policy.tax import TaxOn, TaxScenario, TaxType
demand = Line.from_inverse(10.0, -1.0)
supply = Line.from_inverse(0.0, 1.0)
scenario = TaxScenario(tax_type=TaxType.AD_VALOREM_TAX, amount=0.2, tax_on=TaxOn.CONSUMER)
fig = MarketFigure(x_max=11, y_max=11, title="Ad Valorem Tax", palette="monochrome")
fig.add_curves(demand, supply, q_max=10)
fig.add_tax_transform(demand, supply, scenario, q_max=10)
fig.finalize(legend=True)
fig.save("tax_ad_valorem_consumer.png")
fig.close()
CLI
principle-econ equilibrium \
--demand-intercept 10 --demand-slope -1 \
--supply-intercept 2 --supply-slope 1
principle-econ tax \
--demand-intercept 10 --demand-slope -1 \
--supply-intercept 2 --supply-slope 1 \
--tax-type per_unit --amount 1 --tax-on producer
Examples
Run all examples:
poetry run python examples/scipts/run_all.py
Generated images are grouped by topic under examples/output/:
equilibrium/taxation/price_controls/welfare/elasticity/
Development
poetry run ruff check src tests examples/scipts
poetry run pytest -q
poetry build
PyPI Publishing
This repository is configured to publish from GitHub Actions using Trusted Publishing.
- Workflow:
.github/workflows/publish.yml - Trigger: push tag
v*(for examplev0.1.0) - Publisher:
pypa/gh-action-pypi-publish@release/v1withid-token: write
Release helper script (modeled after econ-viz):
scripts/release.sh prepare 0.1.0
scripts/release.sh finalize 0.1.0
Documentation
- Architecture:
docs/architecture.md - Contribution guide:
CONTRIBUTING.md - Changelog:
CHANGELOG.md
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file principle_econ-0.1.0.tar.gz.
File metadata
- Download URL: principle_econ-0.1.0.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1557e202b015691d4a51f8dc4d578c63d0eec7f361908bf3bef9f3acf1d5ddc4
|
|
| MD5 |
660d40e44583c66c1c22ed070fd3d8d7
|
|
| BLAKE2b-256 |
4047a9143798779607c2bceb7406c6777c3d80e6faa6d3557131b7466194e664
|
Provenance
The following attestation bundles were made for principle_econ-0.1.0.tar.gz:
Publisher:
publish.yml on EconViz/principle-econ
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
principle_econ-0.1.0.tar.gz -
Subject digest:
1557e202b015691d4a51f8dc4d578c63d0eec7f361908bf3bef9f3acf1d5ddc4 - Sigstore transparency entry: 1372450715
- Sigstore integration time:
-
Permalink:
EconViz/principle-econ@48536cc82fb08d8d6673b02dbb97977f4f2032c0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/EconViz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@48536cc82fb08d8d6673b02dbb97977f4f2032c0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file principle_econ-0.1.0-py3-none-any.whl.
File metadata
- Download URL: principle_econ-0.1.0-py3-none-any.whl
- Upload date:
- Size: 35.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
effb07ee6ae75ad5dccb33cf53b0df0ae832d197c3d71d7560e70dbf11868575
|
|
| MD5 |
4377780ff993917e3e5252997aeb0548
|
|
| BLAKE2b-256 |
f72b605f461099f57da828051d7d3e4557c5a3d5b3a2682416c5c3645698ee8a
|
Provenance
The following attestation bundles were made for principle_econ-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on EconViz/principle-econ
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
principle_econ-0.1.0-py3-none-any.whl -
Subject digest:
effb07ee6ae75ad5dccb33cf53b0df0ae832d197c3d71d7560e70dbf11868575 - Sigstore transparency entry: 1372451127
- Sigstore integration time:
-
Permalink:
EconViz/principle-econ@48536cc82fb08d8d6673b02dbb97977f4f2032c0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/EconViz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@48536cc82fb08d8d6673b02dbb97977f4f2032c0 -
Trigger Event:
push
-
Statement type: