Registry / data / kafe2
library2.11.0pypypi✓ verified 85d ago

kafe2 (Karlsruhe Fit Environment 2) is an open-source Python package (current version 2.11.0) for likelihood-based parameter estimation and elementary data analysis. Primarily used for fitting models to measured data and visualizing results, it provides a user-friendly interface for state-of-the-art statistical methods, relying on established numerical and optimization libraries like NumPy and SciPy. The library aims to offer an easy-to-use and performance-optimized pipeline for data analysis, including parameter confidence intervals and publication-quality plots. It typically sees a few releases per year.

pip install kafe2
INSTALL
IMPORT
SIG · KAFE2
K
kafe2
datapythonv2.11.0
Install
16.5s avg
Import
6856ms
Disk
405MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.11.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 7.045s · 390.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 16.5s · import 6.666s · 375MB
405MB installed
● package 405MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

kafe2
import kafe2
For simplified functional interface (e.g., kafe2.xy_fit, kafe2.plot).
XYFit, Plot, XYContainer, ContoursProfiler
from kafe2 import XYFit, Plot, XYContainer, ContoursProfiler
For the object-oriented interface, import specific classes as needed.

This quickstart demonstrates a simple linear fit to x-y data with errors, using kafe2's simplified functional interface. It defines data, performs the fit, and then visualizes the results.

import kafe2 import numpy as np import matplotlib.pyplot as plt # 1. Define your data x_data = np.array([1.0, 2.0, 3.0, 4.0]) y_data = np.array([2.3, 4.2, 7.5, 9.4]) # 2. Perform a fit using the simplified functional interface # A 'line' model is used by default if not specified explicitly. fit_object = kafe2.xy_fit( "line", x_data, y_data, x_error=0.1, y_error=[0.40, 0.45, 0.40, 0.25] # Point-wise y errors ) # 3. Plot the results plot_object = kafe2.plot(fit_object, x_label="$t$ [s]", y_label="$h$ [m]") plt.show()
Debug
Known issues
breakingArgument order for all wrapper functions (e.g., `xy_fit`, `hist_fit`) changed in v2.8.0. The model function is now accepted as the first argument, followed by the data.
fix
Update calls to wrapper functions to place the model function (or model name string) as the first argument, followed by data arguments. E.g., `kafe2.xy_fit(model_func, x_data, y_data)` instead of `kafe2.xy_fit(x_data, y_data, model_func)`.
affects: >=2.8.0
breakingPython version support has changed across minor releases. Python 3.6 was dropped in v2.8.1, and Python 3.8 was dropped in v2.11.0. Python 3.13 was added in v2.11.0.
fix
Ensure your Python environment meets the current requirements. For v2.11.0, Python >=3.9 and <=3.13 are officially supported.
affects: >=2.8.1, >=2.11.0
gotchaThe optional `iminuit` minimizer, if used, requires a C++ compiler to be available on your system during installation. Installation may fail or default to SciPy's minimizers if not present.
fix
Install a C++ compiler (e.g., Build Tools for Visual Studio on Windows, build-essential on Debian/Ubuntu, or Xcode Command Line Tools on macOS) before installing `iminuit` or `kafe2` with `iminuit` dependencies.
affects: All versions
gotchaAs of v2.11.0, the model function code consistently uses function signatures instead of bytecode. While this enables overriding `__signature__`, custom model functions that relied on specific bytecode introspection might behave differently.
fix
Review custom model function implementations, especially if you were manipulating their internal representation. Standard Python function definitions should work as expected.
affects: >=2.11.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'kafe2'
The kafe2 library is either not installed in your Python environment or the active Python interpreter does not have access to the installed package.
fix
Ensure kafe2 is installed in your environment by running: `pip install kafe2`
ModuleNotFoundError: No module named 'iminuit'
The 'iminuit' package, which kafe2 uses as its default and recommended minimizer, is not installed. This often happens if its installation failed due to a missing C++ compiler on the system.
fix
First, ensure you have a C++ compiler installed (e.g., build-essential on Linux, Xcode command line tools on macOS, Visual C++ Build Tools on Windows), then install iminuit: `pip install iminuit`
KeyError: 'Parameter <parameter_name> not found in model function arguments.'
You are trying to fix, limit, or constrain a parameter using a name that does not exactly match one of the argument names defined in your model function.
fix
Verify that the string provided for the parameter name (e.g., in `fit.fix_parameter('param_name', value)`) precisely matches an argument name in your model function definition.
TypeError: add_error() got an unexpected keyword argument '<invalid_argument>'
You are attempting to add uncertainties to a data container using incorrect or unrecognized keyword arguments for the `add_error` method (e.g., using `err_val_rel` instead of `relative=True`).
fix
Consult the kafe2 documentation for the specific data container type (e.g., `XYContainer`, `IndexedContainer`) to ensure you are using the correct keyword arguments such as `axis`, `err_val`, `correlation`, and `relative`.
Upgrade
Version history
2.11.0latest on PyPI · released Oct 23, 2025
Audit
Dependencies
numpyrequiredCore for numerical operations.
numdifftoolsrequiredFor numerical differentiation, replaced scipy.misc.derivative.
scipyrequiredCore for scientific computing, used for optimization.
matplotlibrequiredFor plotting and visualization of fit results.
tabulaterequiredFor presenting tabular data, likely in reports.
pyyamlrequiredFor handling YAML configuration files, particularly for the kafe2go CLI.
iminuitoptionalOptional but recommended minimizer backend for numerical optimization, alternative to SciPy's minimizers.
Agent activity
6 hits · last 30 days
node
6
Resources
kafe2 — pip install kafe2 · libregistry