Skip to main content

OpenFisca Core

PyPi Downloads PyPi Version

Python Contributors

Newsletter Twitter Slack

OpenFisca is a versatile microsimulation free software. Check the online documentation for more details.

This package contains the core features of OpenFisca, which are meant to be used by country packages such as OpenFisca-France. Bootstrapping your own country package should not take more than 5 minutes: check our country package template.

Environment

OpenFisca runs on Python. See pyproject.toml for supported versions.

OpenFisca also relies strongly on NumPy. The last four minor versions should work, but only the latest/stable is tested.

Installation

If you're developing your own country package, you don't need to explicitly install OpenFisca-Core. It just needs to appear in your package dependencies. If you want to contribute to OpenFisca-Core itself, welcome! To install it locally we recommend to use uv.

Installing openfisca-core with uv

This installation requires Python and GIT installations.

To install openfisca-core locally in development mode run the following commands in a shell terminal:

git clone https://github.com/openfisca/openfisca-core.git
cd openfisca-core
make test

Testing

For integration testing purposes, openfisca-core relies on country-template and extension-template. Because these packages rely at the same time on openfisca-core, they need to be installed separately.

To run the entire test suite:

make test

If you have many tests, you could run them in parallel :

uv run make test-core openfisca_args="--in-parallel"

You could add an option --num-workers=4 to limit to 4 threads. Default is your CPU Core number minus 1.

Be aware that this add overhead so use it only for huge test suite.

To run all the tests defined on a test file:

uv run pytest tests/core/test_parameters.py

To run a single test:

uv run pytest tests/core/test_parameters.py -k test_parameter_for_period

Types

This repository relies on MyPy for optional dynamic & static type checking.

As NumPy introduced the typing module in 1.20.0, to ensure type hints do not break the code at runtime, we run the checker against the last four minor NumPy versions.

Type checking is already run with make test. To run the type checker alone:

make check-types

Style

This repository adheres to a certain coding style, and we invite you to follow it for your contributions to be integrated promptly.

Style checking is already run with make test. To run the style checker alone:

make check-style

To automatically style-format your code changes:

make format-style

To automatically style-format your code changes each time you commit:

touch .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

tee -a .git/hooks/pre-commit << END
#!/bin/bash
#
# Automatically format your code before committing.
# Change .venv/bin/activate if your virtual environment is located elsewhere.
source .venv/bin/activate
exec make format-style
exec make check-style
END

Documentation

OpenFisca’s toolchain checks whether documentation builds correctly and updates it automatically with each contribution to this repository.

In the meantime, please take a look at our contributing guidelines for some general tips on how to document your contributions, and at our official documentation's repository to in case you want to know how to build it by yourself —and improve it!

Serving the API

OpenFisca-Core provides a Web-API. It is by default served on the 5000 port.

To run it with the mock country package openfisca_country_template and another port value such as 2000, run:

openfisca serve --country-package openfisca_country_template --port 2000

To read more about the openfisca serve command, check out its documentation.

By default, the Web API uses 3 workers to avoid this issue. Without it, AJAX requests from Chrome sometimes take more than 20s to process. You can change the number of workers by specifying a --workers k option.

You can test that the API is running by executing the command:

curl http://localhost:2000/parameters

For more information about endpoints and input formatting, see the official documentation.

Metadata

Release files for OpenFisca-Core-test 46.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for OpenFisca-Core-test 46.0.5
File Size Uploaded
openfisca_core_test-46.0.5.tar.gz 227.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for OpenFisca-Core-test 46.0.5
File Interpreter ABI Platform
openfisca_core_test-46.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 525.8 kB

Release files / openfisca_core_test-46.0.5.tar.gz

Download URL openfisca_core_test-46.0.5.tar.gz
Size 227.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d2c257d2efcb810359b4ce12e1d886cb64c343338642e7e77b6bc6307aad0c9c
BLAKE2b-256 checksum
How to use checksums
a70c602199efdf6f4b11e7689c49ac6cffd6d2de5e1659d58acb57453bb52bf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / openfisca_core_test-46.0.5-py3-none-any.whl

Download URL openfisca_core_test-46.0.5-py3-none-any.whl
Size 298.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1a33b8823c65f906b3b4bd6901cfe79a5f668c9522916ba90d0c2a06e8b2848
BLAKE2b-256 checksum
How to use checksums
9261ecda04cc7882c217f426df2ffa7120886efad50076a3e5ccefd87b9d5b48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

46.0.5 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page