Skip to content

Commit

Permalink
Merge pull request #43 from lbl-srg/issue42_syslogCheck
Browse files Browse the repository at this point in the history
Issue42 syslog check
  • Loading branch information
AntoineGautier authored May 13, 2020
2 parents fcb6cc2 + 1468500 commit d24e60a
Show file tree
Hide file tree
Showing 24 changed files with 602 additions and 350 deletions.
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Binaries
bin/*
!bin/*.py
*.py[cod]

# Object files
*.o

# Tests outputs
tests/**/*.html
tests/test_numerics*/*
tests/test_numerics*/

# Generated by CMake
DartConfiguration.tcl
build/*
build/

# Generated by development tools
.vscode/*
.vscode/
*.pyc
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: c

python:
- "2.7"
- "3.6"

notifications:
email: false
Expand All @@ -24,19 +25,22 @@ matrix:
before_install:
- choco install python2
- export PATH="/c/Python27:/c/Python27/Scripts:$PATH"
- python -m pip install --upgrade pip wheel

before_install:
- python -m pip install --user --upgrade pip

install:
- pip install --user -r requirements.txt
- pip install --user .

before_script:
- mkdir build && cd build && cmake .. $ARCH_OPTION
- rm -rf build && mkdir build && cd build && cmake .. $ARCH_OPTION

script:
# Compile, link, install.
- cmake --build . --target install --config Release
# Test and clean.
- ctest -C Release && python ../tests/test_summary.py ../tests
- ctest -C Release
# Compare.
- git status tests
- git diff --exit-code tests
35 changes: 21 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

cmake_policy(SET CMP0048 NEW)
cmake_minimum_required(VERSION 3.11.0)
project(funnel VERSION 0.1.0 LANGUAGES C)
file(READ "${CMAKE_SOURCE_DIR}/pyfunnel/VERSION" VERSION)
project(funnel VERSION ${VERSION} LANGUAGES C)
enable_testing()

# Detect OS.
Expand All @@ -35,10 +36,6 @@ else()
message(WARNING "OS unknown!")
endif()

# Output build system directories.
message("CMake source directory is: ${CMAKE_SOURCE_DIR}")
message("CMake binary directory is: ${CMAKE_BINARY_DIR}")

# Set compiling and linking options.
# Consider adding -std=c89 -pedantic to gcc options to improve portability.
set(UNIX_COMPILE_FLAGS "-Wall -Wfloat-equal -o3 -fPIC")
Expand Down Expand Up @@ -70,10 +67,14 @@ elseif(MACOSX)
set(PLATFORM_INSTALL_PREFIX darwin64)
endif()

set(ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib/${PLATFORM_INSTALL_PREFIX}")
set(LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib/${PLATFORM_INSTALL_PREFIX}")
set(RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(PUBLIC_INCLUDE_DIRECTORY "${CMAKE_SOURCE_DIR}/include")
set(ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/pyfunnel/lib/${PLATFORM_INSTALL_PREFIX}")
set(LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/pyfunnel/lib/${PLATFORM_INSTALL_PREFIX}")

# Print build system directories.
message("CMake source directory is: ${CMAKE_SOURCE_DIR}")
message("CMake binary directory is: ${CMAKE_BINARY_DIR}")
message("CMake archive directory is: ${ARCHIVE_OUTPUT_DIRECTORY}")
message("CMake library directory is: ${LIBRARY_OUTPUT_DIRECTORY}")

# Manage subdirectories.
add_subdirectory(src)
Expand Down Expand Up @@ -105,30 +106,30 @@ add_test(
set(TEST_ARGS_0 --reference trended.csv --test simulated.csv --atolx 0.002 --atoly 0.002 --output results)
add_test(
NAME test_py_0
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/bin/pyfunnel.py" ${TEST_ARGS_0}
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/pyfunnel/pyfunnel.py" ${TEST_ARGS_0}
WORKING_DIRECTORY "${CMAKE_TEST_DIR}/test_bin"
)
### Wrong arguments
set(TEST_ARGS_1 --reference wrong.csv --test simulated.csv --atolx 0.002 --atoly 0.002 --output results)
add_test(
NAME test_py_1
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/bin/pyfunnel.py" ${TEST_ARGS_1}
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/pyfunnel/pyfunnel.py" ${TEST_ARGS_1}
WORKING_DIRECTORY "${CMAKE_TEST_DIR}/test_bin"
)
set_tests_properties(test_py_1 PROPERTIES PASS_REGULAR_EXPRESSION "No such file")
### Again
set(TEST_ARGS_2 --reference trended.csv --test simulated.csv --atoly 0.002 --output results)
add_test(
NAME test_py_2
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/bin/pyfunnel.py" ${TEST_ARGS_2}
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/pyfunnel/pyfunnel.py" ${TEST_ARGS_2}
WORKING_DIRECTORY "${CMAKE_TEST_DIR}/test_bin"
)
set_tests_properties(test_py_2 PROPERTIES PASS_REGULAR_EXPRESSION "At least one of the two possible tolerance parameters")
### Again
set(TEST_ARGS_3 --reference trended.csv --test simulated.csv --atolx 0.002 --atoly 0.002)
add_test(
NAME test_py_3
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/bin/pyfunnel.py" ${TEST_ARGS_3}
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/pyfunnel/pyfunnel.py" ${TEST_ARGS_3}
WORKING_DIRECTORY "${CMAKE_TEST_DIR}/test_bin"
)
set_tests_properties(test_py_3 PROPERTIES PASS_REGULAR_EXPRESSION "Output directory not specified")
Expand Down Expand Up @@ -173,9 +174,15 @@ add_test(
set_tests_properties(test_plot PROPERTIES FAIL_REGULAR_EXPRESSION "Exception;Error;Traceback")

## Configure pre/post test.
set(summary_path "${CMAKE_TEST_DIR}/test_summary.py")
set(CTEST_CUSTOM_POST_TEST
"${PYTHON_EXECUTABLE} ${summary_path} ${CMAKE_TEST_DIR}"
)
set(content "# Numerics testing configuration file
set(CTEST_CUSTOM_PRE_TEST
${CTEST_CUSTOM_PRE_TEST})"
${CTEST_CUSTOM_PRE_TEST})
set(CTEST_CUSTOM_POST_TEST
\"${CTEST_CUSTOM_POST_TEST}\")"
)
file(WRITE
"${CMAKE_BINARY_DIR}/CTestCustom.cmake"
Expand Down
6 changes: 3 additions & 3 deletions COPYRIGHT.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright Notice

"funnel v0.0.1" Copyright (c) 2018, The Regents of the University of California,
"funnel" Copyright (c) 2018, The Regents of the University of California,
through Lawrence Berkeley National Laboratory (subject to receipt of any required
approvals from the U.S. Dept. of Energy). All rights reserved.
approvals from the U.S. Dept. of Energy). All rights reserved.

If you have questions about your rights to use or distribute this software, please
contact Berkeley Lab's Innovation & Partnerships Office at [email protected].
Expand All @@ -12,4 +12,4 @@ Energy and the U.S. Government consequently retains certain rights. As such,
the U.S. Government has been granted for itself and others acting on its behalf
a paid-up, non-exclusive, irrevocable, worldwide license in the Software to
reproduce, distribute copies to the public, prepare derivative works, and perform
publicly and display publicly, and to permit others to do so.
publicly and display publicly, and to permit others to do so.
18 changes: 9 additions & 9 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# License Agreement

"funnel v0.0.1" Copyright (c) 2018, The Regents of the University of California,
"funnel" Copyright (c) 2020, The Regents of the University of California,
through Lawrence Berkeley National Laboratory (subject to receipt of any required
approvals from the U.S. Dept. of Energy). All rights reserved.
approvals from the U.S. Dept. of Energy). All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
1. Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

(1) Redistributions of source code must retain the above copyright notice, this
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

(2) Redistributions in binary form must reproduce the above copyright notice,
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

(3) Neither the name of the University of California, Lawrence Berkeley National
3. Neither the name of the University of California, Lawrence Berkeley National
Laboratory, U.S. Dept. of Energy nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior
written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
Expand All @@ -30,12 +30,12 @@ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

You are under no obligation whatsoever to provide any bug fixes, patches, or
3. You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
("Enhancements") to anyone; however, if you choose to make your Enhancements
available either publicly, or directly to Lawrence Berkeley National Laboratory,
without imposing a separate written license agreement for such Enhancements,
then you hereby grant the following license: a non-exclusive, royalty-free
perpetual license to install, use, modify, prepare derivative works, incorporate
into other computer software, distribute, and sublicense such enhancements
or derivative works thereof, in binary and source code form.
or derivative works thereof, in binary and source code form.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include pyfunnel/VERSION
recursive-include pyfunnel/templates *
43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

A cross-platform C-based software for comparing two `(x, y)` data sets given tolerances in `x` and `y` directions.

Handles: different time (`x`) scales, time events offsets, relative and absolute tolerances
in `x` and `y` directions.

## Principles

### Overall
Expand Down Expand Up @@ -54,19 +51,30 @@ By convention, the error is `max(0, y - y_up) - min(0, y - y_low)` and hence it

### System Requirements

The software has been tested on the following platforms for which a library is provided in `./lib`:
The software has been tested on the following platforms.

* Linux x64
* Windows x64
* Mac OS X

The Python binding has been tested with Python `2.7.*` and `3.7.*`.
See `requirements.txt` for the required Python packages.
A Python binding is available to access the library. It is compatible with Python 2 and 3.

### Installing

The Python binding is delivered as a package named `pyfunnel`.

The package is not published on PyPI but can be installed from GitHub with

`pip git+https://github.com/lbl-srg/funnel.git@master`

### Python Binding
For development, additional dependencies are needed and can be installed with

`pip install -r requirements.txt`

### Main Functions

The software is primarily intended to be used by means of a Python binding.
The module `./bin/pyfunnel.py` provides the following functions:
The package `pyfunnel` provides the following functions.

* `compareAndReport`: calls `funnel` binary with list-like objects as `x`, `y` reference and test values.
Outputs `errors.csv`, `lowerBound.csv`, `upperBound.csv`, `reference.csv`, `test.csv`
Expand All @@ -77,7 +85,8 @@ The module `./bin/pyfunnel.py` provides the following functions:
* `plot_funnel`: plots `funnel` results stored in the directory which path is provided as argument.
Displays plot in default browser. See function docstring for further details.

The module might also be called directly from terminal:
The module `pyfunnel.py` might also be called directly from terminal.

```
usage: pyfunnel.py [-h] --reference REFERENCE --test TEST [--output OUTPUT]
[--atolx ATOLX] [--atoly ATOLY] [--rtolx RTOLX]
Expand Down Expand Up @@ -111,23 +120,19 @@ Full documentation at https://github.com/lbl-srg/funnel

### Example

From a Python shell with `./tests/test_bin` as the current working directory, type
From a Python shell with `./tests/test_bin` as the current working directory, run
```python
>>> import os
>>> import sys
>>> import pandas as pd
>>> pyfunnel_dir = os.path.join(os.path.pardir, os.path.pardir, 'bin')
>>> sys.path.append(pyfunnel_dir)
>>> import pyfunnel
>>> ref = pd.read_csv('trended.csv')
>>> test = pd.read_csv('simulated.csv')
>>> pyfunnel.compareAndReport(xReference=ref.iloc(axis=1)[0], yReference=ref.iloc(axis=1)[1],
... xTest=test.iloc(axis=1)[0], yTest=test.iloc(axis=1)[1], atolx=0.002, atoly=0.002)
>>> pyfunnel.plot_funnel('results')
```
Or from a terminal with `./tests/test_bin` as the current working directory, type
Or from a terminal with `./tests/test_bin` as the current working directory, run
```
$ python ../../bin/pyfunnel.py --reference trended.csv --test simulated.csv --atolx 0.002 --atoly 0.002
$ python ../../pyfunnel/pyfunnel.py --reference trended.csv --test simulated.csv --atolx 0.002 --atoly 0.002
```

## Build from Source
Expand All @@ -141,7 +146,7 @@ The distributed binaries have been built with Microsoft Visual Studio C/C++ comp

### Procedure

To compile, link and install, from the top-level directory, run the following commands:
To compile, link and install, from the top-level directory, run the following commands

```
mkdir build
Expand All @@ -150,10 +155,10 @@ cmake .. (add `-A x64` on Windows to compile in 64 bit
cmake --build . --target install (add `--config Release` on Windows)
```

To run the tests, from `./build` run the following commands:
To run the tests, from `./build` run

```
ctest (add `-C Release` on Windows)
python ../tests/test_summary.py ../tests
```

## License
Expand Down
Empty file removed __init__.py
Empty file.
Empty file removed bin/__init__.py
Empty file.
Binary file removed lib/linux64/libfunnel.so
Binary file not shown.
1 change: 1 addition & 0 deletions pyfunnel/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
18 changes: 18 additions & 0 deletions pyfunnel/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Python binding for funnel library.
"""

from __future__ import absolute_import

import os

from .core import compareAndReport, MyHTTPServer, CORSRequestHandler, plot_funnel

# Version.
version_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'VERSION'))
with open(version_path) as f:
__version__ = f.read().strip()

Loading

0 comments on commit d24e60a

Please sign in to comment.