Skip to content

Commit

Permalink
Python project renamed pyrfc -> rfcnt
Browse files Browse the repository at this point in the history
  • Loading branch information
a-ma72 committed Aug 11, 2021
1 parent 29680dd commit 7fcd6aa
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ rainflow\.sublime-workspace
/python/build
/python/venv
/python/dist
/python/pyrfc*
/python/rfcnt*
/python/MANIFEST
/src/config.h
8 changes: 4 additions & 4 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project(pyrfc)
project(rfcnt)

# Find Python 3
find_package(Python3 COMPONENTS Interpreter Development)
Expand All @@ -13,6 +13,6 @@ if(NUMPY_NOT_FOUND)
message(FATAL_ERROR "NumPy headers not found")
endif()

add_library(pyrfc SHARED pyrfc.cpp)
target_include_directories(pyrfc PRIVATE ${_Python3_INCLUDE_DIR})
target_link_libraries(pyrfc PRIVATE ${_Python3_LIBRARY_RELEASE})
add_library(rfcnt SHARED rfcnt.cpp)
target_include_directories(rfcnt PRIVATE ${_Python3_INCLUDE_DIR})
target_link_libraries(rfcnt PRIVATE ${_Python3_LIBRARY_RELEASE})
25 changes: 25 additions & 0 deletions python/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License

Copyright (c) 2019, Andreas Martin
All rights reserved.

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

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

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

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 HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY 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.
1 change: 1 addition & 0 deletions python/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include src/rainflow.c
include src/rainflow.h
include src/rainflow.hpp
LICENSE
8 changes: 4 additions & 4 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## **pyrfc** a rainflow counting algorithm Python package
## **rfcnt** a rainflow counting algorithm Python package

### "Rainflow Counting" consists of four main steps:

Expand All @@ -22,13 +22,13 @@ To take the residue into account, you may implement a custom method or use some
predefined functions.

### Install
pip install _{packagename}_.tar.gz
pip install {packagename}.tar.gz
where _{packagename}_ is the current package release, for example:

pip install pyrfc-0.1.0.tar.gz
pip install rfcnt-0.1.0.tar.gz

### Test
_pyrfc_ packages include some unit tests, which can be run:
_rfcnt_ packages include some unit tests, which can be run:

python run_tests.py

Expand Down
6 changes: 3 additions & 3 deletions python/run_examples.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import sys
from pyrfc.test import examples
from rfcnt.tests import examples

print( "Running example 1..." )
examples.example_1()


"""
Jupyter Notebook:
!pip install ./pyrfc-0.1.0.tar.gz
!pip install ./rfcnt-0.1.0.tar.gz
!pip install --upgrade matplotlib
from pyrfc.test import examples
from rfcnt.tests import examples
examples.example_1()
"""
4 changes: 2 additions & 2 deletions python/run_tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from pyrfc.test import test
from rfcnt.tests import test_rfcnt
from unittest.case import TestCase
import unittest
from io import StringIO
from pprint import pprint

stream = StringIO()
runner = unittest.TextTestRunner(stream=stream)
result = runner.run(unittest.makeSuite(test.TestRainflowCounting))
result = runner.run(unittest.makeSuite(test_rfcnt.TestRainflowCounting))
print( 'Tests run ', result.testsRun )
print( 'Errors ', result.errors )
pprint(result.failures)
Expand Down
16 changes: 8 additions & 8 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def main():
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()

setup(name="pyrfc",
setup(name="rfcnt",
version="%d.%d.%d" % version,
description="Python interface for rainflow counting",
long_description=long_description,
Expand All @@ -23,12 +23,12 @@ def main():
license='BSD-2-Clause License',
url='http://github.com/AndreasMartin72/rainflow',
install_requires=['numpy'],
py_modules=["pyrfc.utils", "pyrfc.examples"],
packages=["pyrfc", "pyrfc.test"],
package_dir={"pyrfc": "", "pyrfc.test": "test"},
package_data={"pyrfc": ["run_examples.py", "run_tests.py", "requirements.txt", "README.md"],
"pyrfc.test": ["long_series.csv"]},
ext_modules=[Extension("pyrfc.pyrfc", ["src/pyrfc.cpp", "src/rainflow.c"],
py_modules=["rfcnt.utils", "rfcnt.examples"],
packages=["rfcnt", "rfcnt.tests"],
package_dir={"rfcnt": "", "rfcnt.tests": "tests"},
package_data={"rfcnt": ["run_examples.py", "run_tests.py", "requirements.txt", "README.md", "LICENSE"],
"rfcnt.tests": ["long_series.csv"]},
ext_modules=[Extension("rfcnt.rfcnt", ["src/rfcnt.cpp", "src/rainflow.c"],
define_macros=[
('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION'),
('RFC_HAVE_CONFIG_H', '0'),
Expand Down Expand Up @@ -62,7 +62,7 @@ def main():
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python : 3',
'Programming Language :: Python :: 3',
'Programming Language :: C++',
'Programming Language :: C',
'Topic :: Scientific/Engineering',
Expand Down
4 changes: 2 additions & 2 deletions python/src/pyrfc.cpp → python/src/rfcnt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ PyMethodDef method_table[] = {
// A struct contains the definition of a module
PyModuleDef mymath_module = {
PyModuleDef_HEAD_INIT,
"pyrfc", // Module name
"rfcnt", // Module name
"Rainflow counting module",
-1, // Optional size of the module state memory
method_table,
Expand All @@ -432,7 +432,7 @@ PyModuleDef mymath_module = {


// The module init function
PyMODINIT_FUNC PyInit_pyrfc(void) {
PyMODINIT_FUNC PyInit_rfcnt(void) {
PyObject* mod = PyModule_Create(&mymath_module);
// Initialize numpy
import_array();
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions python/test/examples.py → python/tests/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from pyrfc import pyrfc, utils # Rainflow module (ftc2)
from rfcnt import rfcnt, utils # Rainflow module (ftc2)
import os
import sys

Expand All @@ -18,7 +18,7 @@ def example_1():
class_width = class_range / (class_count - 1)
class_offset = data.min() - class_width / 2

res = pyrfc.rfc(data, class_count=class_count,
res = rfcnt.rfc(data, class_count=class_count,
class_offset=class_offset,
class_width=class_width,
hysteresis=class_width,
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions python/test/test.py → python/tests/test_rfcnt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import unittest
from pyrfc import pyrfc
from rfcnt import rfcnt
import numpy as np
import pandas as pd

Expand Down Expand Up @@ -37,7 +37,7 @@ def test_empty_series( self ):
residual_method = 0 # No processing on residue
spread_damage = 0 # No damage spreading

res = pyrfc.rfc( x, class_count=class_count,
res = rfcnt.rfc( x, class_count=class_count,
class_width=class_width,
class_offset=class_offset,
hysteresis=hysteresis,
Expand All @@ -64,7 +64,7 @@ def test_single_cycle_up( self ):
residual_method = 0 # No processing on residue
spread_damage = 0 # No damage spreading

res = pyrfc.rfc( x, class_count=class_count,
res = rfcnt.rfc( x, class_count=class_count,
class_width=class_width,
class_offset=class_offset,
hysteresis=hysteresis,
Expand Down Expand Up @@ -92,7 +92,7 @@ def test_one_cycle_down( self ):
residual_method = 0 # No processing on residue
spread_damage = 0 # No damage spreading

res = pyrfc.rfc( x, class_count=class_count,
res = rfcnt.rfc( x, class_count=class_count,
class_width=class_width,
class_offset=class_offset,
hysteresis=hysteresis,
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_small_sample( self ):
residual_method = 0 # No processing on residue
spread_damage = 0 # No damage spreading

res = pyrfc.rfc( x, class_count=class_count,
res = rfcnt.rfc( x, class_count=class_count,
class_width=class_width,
class_offset=class_offset,
hysteresis=hysteresis,
Expand Down Expand Up @@ -153,7 +153,7 @@ def test_long_series( self ):
residual_method = 0 # 0=RFC_RES_NONE, 7=RFC_RES_REPEATED
spread_damage = 1 # 0=RFC_SD_HALF_23, 1=RFC_SD_RAMP_AMPLITUDE_23

res = pyrfc.rfc( x, class_count=class_count,
res = rfcnt.rfc( x, class_count=class_count,
class_width=class_width,
class_offset=class_offset,
hysteresis=hysteresis,
Expand All @@ -169,7 +169,7 @@ def test_long_series( self ):

spread_damage = 8; # 7=RFC_SD_TRANSIENT_23, 8=RFC_SD_TRANSIENT_23c

res = pyrfc.rfc( x, class_count=class_count,
res = rfcnt.rfc( x, class_count=class_count,
class_width=class_width,
class_offset=class_offset,
hysteresis=hysteresis,
Expand Down

0 comments on commit 7fcd6aa

Please sign in to comment.