catala/french_law/python
Louis Gesbert deb12d2c4a Bump version to 0.8.0
Changelog:
---

A lot has been going on, with more than 530 patches and 70 PRs merged since
0.7.0 last summer. In summary:

- Quite a lot of syntax improvements and changes. Checkout the latest
  [cheat-sheet](https://catalalang.github.io/catala/syntax.pdf) for an overview

- Allow local `let ... equals ... in ...` definitions

- Better error messages and positions throughout

- Added the ability to directly call a scope and retrieve its outputs, like a
  function

- Added disambiguation, allowing to access structure fields without specifying
  the structure type each time

- Added automated resolution of operators, allowing e.g. to write just `+` in
  place of all the type-specific operators `+.`, `+$`, `+@`, `+^`, etc.

- More consistent priority for operators. It is no longer allowed to write `a
  and b or c` without parenthesis.

- Added and changed some operators (`date + duration` now allowed either way,
  `int / int` now returns a decimal, added `duration / duration`)

- Added the ability to have variables and functions defined at
  top-level (outside of any scope). See annex A of the tutorial for details.

- Added support for functions with multiple arguments

- Some big refactors in the compiler, allowing much better code sharing between
  the different passes, and making it much easier to extend. Also added the
  possibility to run the type-checker earlier, etc.

- Countless bug-fixes

- Improvements to our proof backend with Z3

- A tool to automatically synchronise with the upstream French law from
  Legifrance
2023-03-08 18:07:53 +01:00
..
cnaf_cross_tester A new case 2022-09-28 16:03:14 +02:00
src Bump version to 0.8.0 2023-03-08 18:07:53 +01:00
.gitignore Various bugfixing and improvements for the Python backend 2021-06-25 00:16:21 +02:00
main.py Correctly bench 2022-09-26 13:28:07 +02:00
Makefile Correctly bench 2022-09-26 13:28:07 +02:00
README.md Refactor Python dependency handling 2023-03-02 16:24:53 +01:00
requirements.txt reference runtime package in Makefile and requirements 2022-05-05 14:01:09 +02:00

Python French Law Library

This folder contains a ready-to-use Python library featuring French public algorithms coded up in Catala.

The Python version expected to run the Python code is above 3.6. For the commands noted below to run, you are expected to setup a virtual Python environment: run make dependencies-python from the root of the Catala repository.

Then activate the environment (needs to be done every time you open a new shell session). From the root of the Catala repository, run the following command:

. _python_venv/bin/activate

Organization

Law source

The src/ folder contains the Python files generated by the Catala compiler. To update them from the Catala sources, invoke this command from the root of the repository:

make generate_french_law_library_python

The Python files generated by the Catala compiler depends on the catala.runtime package, whose source doe can be found in runtimes/python/catala from the root of the Catala repository.

All theses Python files feature type annotations which can be checked against using the following command inside this directory (french_law/python):

make type

API

To use the algorithms of this library, you can take a look at the example provided in main.py. All the algorithms are centralized with wrappers in api.py, as it is very important internally to wrap all of the input parameters using src/catala.py conversion functions.

You can benchmark the computation using the following command inside this directory (french_law/python):

make bench

Logging

The generated Catala code also features a logging feature that let you inspect each step of the computation, as well as the values flowing through it. You can directly retrieve a list of log events just after using a Catala-generated function, and display this list as you wish. An example of such a display can be showcases by using the following command inside this directory (french_law/python):

make show_log