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
Metadata
Release files for principle-econ 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| principle_econ-0.1.0.tar.gz | 22.9 kB | With provenance | Details for principle_econ-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| principle_econ-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for principle_econ-0.1.0-py3-none-any.whl |
Total release size: 58.2 kB
Release files / principle_econ-0.1.0.tar.gz
| Download URL | principle_econ-0.1.0.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1557e202b015691d4a51f8dc4d578c63d0eec7f361908bf3bef9f3acf1d5ddc4
|
|
BLAKE2b-256 checksum How to use checksums |
4047a9143798779607c2bceb7406c6777c3d80e6faa6d3557131b7466194e664
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 24, 2026.
Transparency logRelease files / principle_econ-0.1.0-py3-none-any.whl
| Download URL | principle_econ-0.1.0-py3-none-any.whl |
|---|---|
| Size | 35.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
effb07ee6ae75ad5dccb33cf53b0df0ae832d197c3d71d7560e70dbf11868575
|
|
BLAKE2b-256 checksum How to use checksums |
f72b605f461099f57da828051d7d3e4557c5a3d5b3a2682416c5c3645698ee8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 24, 2026.
Transparency logSecurity for principle-econ 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for principle_econ-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.