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

Install the test dependencies:

make install-deps install-edit install-test

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 :

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:

pytest tests/core/test_parameters.py

To run a single test:

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.2

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.2
File Size Uploaded
openfisca_core_test-46.0.2.tar.gz 227.5 kB Details

Built distribution (wheel)

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

Total release size: 525.7 kB

Release files / openfisca_core_test-46.0.2.tar.gz

Download URL openfisca_core_test-46.0.2.tar.gz
Size 227.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c9fddcc7341434f2dcd956d319e7c6ff0214827682e69800bf5981aa6a9698c3
BLAKE2b-256 checksum
How to use checksums
deff2e0f125feae85bf9f65f67dabe3b1dac260abfc752453a1c153db31be1df
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.2-py3-none-any.whl

Download URL openfisca_core_test-46.0.2-py3-none-any.whl
Size 298.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6fdbf5dac6f1842c370f214cc744eeac09a60efd2607b5c1e8b9f16e8dc5b300
BLAKE2b-256 checksum
How to use checksums
ea4eb1f206a695dd125948d88f5e500e446b247aab9ac25b4651f4a660cd6f80
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.2 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