Skip to main content

Comparison of data fields in files

Project description

FieldCompare

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Test Pipelines. Coverage Report. API Documentation. Code style: black

fieldcompare is a python package with command-line interface (CLI) that can be used to compare datasets for (fuzzy) equality. It was designed mainly to serve as a tool to realize regression tests for research software, and in particular research software that deals with numerical simulations. In regression tests, the output of a software is compared to reference data that was produced by the same software at an earlier time, in order to detect if changes to the code cause unexpected changes to the behavior of the software.

Simulations typically produce discrete field data defined on computational grids, and there exists a variety of standard and widely-used file formats. fieldcompare supports a number of VTK file formats out-of-the box, a variety of further formats can be used with the help of meshio. Besides mesh files, csv files are also supported, a format that is widely used in simulation frameworks to write out secondary data such as e.g. error norms and convergence rates.

Independent of the file type and format, fieldcompare reads all fields from those files and allows you to then check all entries of the fields for equality with custom absolute and relative tolerances. Programmatically, you can provide and use custom predicates (e.g. "smaller-than"), while the CLI is currently hardwired to (fuzzy) equality checks, which is the most common use case.

A common issue with regression testing of grid files is that the grid may be written with a different ordering of points or cells, while the actual field data on the grid may be the same. To this end, fieldcompare provides the option to make the fields read from a grid unique by sorting the grid by its point coordinates and cell connectivity. Moreover, one can choose to strip the grid from ghost points, that may occur, for instance, upon merging the data from multiple grid partitions distributed over different processors.

GitHub Action

If you want to use fieldcompare in your GitHub actions, you may want to check out our fieldcompare action, which allows you to easily perform regression tests within your GitHub workflows.

Installation

After cloning this repository, you can simply install fieldcompare via pip by navigating to the top folder of this repository and then typing python -m pip install .. In case you don't want to install into your system, you can simply create a virtual environment beforehand using venv. The pip command will also install the CLI, which is then available as the fieldcompare command.

Command-line Interface

The CLI exposes two subcommands, namely file and dir, where the former is used to compare two files for equality, and the latter can be used to compare all files with matching names in two given directories. That is, type

fieldcompare file PATH_TO_FILE --reference PATH_TO_REFERENCE_FILE

to compare two files, and

fieldcompare dir PATH_TO_DIR --reference PATH_TO_REFERENCE_DIR

for comparing two directories. The latter command will scan both folders for files with matching names, and then run a file comparison on pairs of matching files. This can be useful if your simulation produces a number of files for which you have references stored in some reference folder, and you want to compare them all in a single command. For more info on the CLI options available, type in

fieldcompare file --help
fieldcompare dir --help

Examples

In examples/api you can find a few examples with instructions on how to use the API of fieldcompare. However, the examples do not cover some of the more advanced functions and classes, but we are planning to add more examples soon.

Contribution Guidelines

Contributions are highly welcome! For bug reports, please file an issue. If you want to contribute with features, improvements or bug fixes please fork this project and open a merge request into the main branch of this repository.

License

fieldcompare is licensed under the terms and conditions of the GNU General Public License (GPL) version 3 or - at your option - any later version. The GPL can be read online or in the LICENSE.txt file in this repository. See LICENSE.txt for full copying permissions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fieldcompare-0.0.9.tar.gz (92.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fieldcompare-0.0.9-py3-none-any.whl (84.7 kB view details)

Uploaded Python 3

File details

Details for the file fieldcompare-0.0.9.tar.gz.

File metadata

  • Download URL: fieldcompare-0.0.9.tar.gz
  • Upload date:
  • Size: 92.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for fieldcompare-0.0.9.tar.gz
Algorithm Hash digest
SHA256 37d9a30110efb6c2f910725253ffa22f5b7330d37a5c5cd83bf168ac9566ed85
MD5 44f9132029afa060e909682ffc1cc5fa
BLAKE2b-256 fe98ac2088860c56f22bab4f18ed1d719b87c32ccde08790206db404c4bcd07c

See more details on using hashes here.

File details

Details for the file fieldcompare-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: fieldcompare-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 84.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for fieldcompare-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ff69df28458254c4992c7839e589a033102343971af436cc9e533fd43332c2fc
MD5 21dc9fb1ed16440fc8ef397a98601f9a
BLAKE2b-256 1b1f6d7a5ab4c85939cb9f76fcfc0897b84a3fb1ece794d1cdf31b0ccb0e581f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page