From baefc7d314c03a3c42f7da6a3cf494fb895158f0 Mon Sep 17 00:00:00 2001 From: par2 Date: Fri, 27 Nov 2015 18:49:29 -0500 Subject: [PATCH 01/15] Add travis config Testing travel builds --- .travis.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c16e67f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: python +python: + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" + - "3.5-dev" # 3.5 development branch +# command to install dependencies +install: "pip install -r requirements.txt" +# command to run tests +#script: nosetests +# +branches: + only: + - master From 9cb6b8ce9a7e155160f23ba51b84db1b2cf57465 Mon Sep 17 00:00:00 2001 From: par2 Date: Fri, 27 Nov 2015 19:08:38 -0500 Subject: [PATCH 02/15] Trigger travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c16e67f..0d0c077 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,3 +14,4 @@ install: "pip install -r requirements.txt" branches: only: - master + - develop From b1daa4c8de289be8469c6b24b4d69c1a78fc24d5 Mon Sep 17 00:00:00 2001 From: par2 Date: Fri, 27 Nov 2015 19:51:50 -0500 Subject: [PATCH 03/15] Test py3.4 first and uncomment 'script' key --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d0c077..cd52665 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,15 @@ language: python python: - - "2.7" - - "3.2" - - "3.3" +# - "2.7" +# - "3.2" +# - "3.3" - "3.4" - - "3.5" - - "3.5-dev" # 3.5 development branch +# - "3.5" +# - "3.5-dev" # 3.5 development branch # command to install dependencies install: "pip install -r requirements.txt" # command to run tests -#script: nosetests +script: nosetests # branches: only: From fb0bdd5328b78a61405d0654a81f161eeb496946 Mon Sep 17 00:00:00 2001 From: par2 Date: Fri, 27 Nov 2015 22:19:12 -0500 Subject: [PATCH 04/15] Configure setup.py for subpackages. --- .travis.yml | 1 - setup.py | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd52665..a8a9527 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: python python: # - "2.7" -# - "3.2" # - "3.3" - "3.4" # - "3.5" diff --git a/setup.py b/setup.py index 71d0143..afa285c 100644 --- a/setup.py +++ b/setup.py @@ -2,14 +2,15 @@ setup( name='lamana', - packages=['lamana'], # this must be the same as the name above - version='0.4.6', ### edit + version='0.4.6', ### edit description='An extensible Python package for Laminate Analysis.', author='P. Robinson II', author_email='par2.get@gmail.com', - url='https://github.com/par2/lamana', # use the URL to the github repo + url='https://github.com/par2/lamana', # use the URL to the github repo download_url='https://github.com/par2/lamana/tarball/0.4.6', + packages=['lamana', 'lamana.models', 'lamana.utils'], keywords=['laminate analysis', 'visualization'], + #install_requires=['matplotlib', 'pandas', 'numpy'], classifiers=[ 'Framework :: IPython', 'Intended Audience :: Science/Research', @@ -29,3 +30,5 @@ # (004) Create package http://zetcode.com/articles/packageinpython/ # (005) Detailed package guide https://python-packaging-user-guide.readthedocs.org/en/latest/ # (006) Updated guide: twine, pip, wheel http://joebergantine.com/blog/2015/jul/17/releasing-package-pypi/ +# (007) packages Python Cookbook, 3rd ed, p. 435 +# (008) install_requires https://python-packaging-user-guide.readthedocs.org/en/latest/requirements/ From 796d88a4311c4e82157cf71f4fd6dde83ec8ad84 Mon Sep 17 00:00:00 2001 From: par2 Date: Fri, 27 Nov 2015 22:37:17 -0500 Subject: [PATCH 05/15] Add tests subpackage --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index afa285c..fbdc70a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ author_email='par2.get@gmail.com', url='https://github.com/par2/lamana', # use the URL to the github repo download_url='https://github.com/par2/lamana/tarball/0.4.6', - packages=['lamana', 'lamana.models', 'lamana.utils'], + packages=['lamana', 'lamana.models', 'lamana.utils', 'lamana.tests'], keywords=['laminate analysis', 'visualization'], #install_requires=['matplotlib', 'pandas', 'numpy'], classifiers=[ From e03b4a642a573ee0b20e50133340e9e5ff2da564 Mon Sep 17 00:00:00 2001 From: par2 Date: Fri, 27 Nov 2015 22:52:21 -0500 Subject: [PATCH 06/15] Add controls_LT folder --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fbdc70a..c144c26 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,8 @@ author_email='par2.get@gmail.com', url='https://github.com/par2/lamana', # use the URL to the github repo download_url='https://github.com/par2/lamana/tarball/0.4.6', - packages=['lamana', 'lamana.models', 'lamana.utils', 'lamana.tests'], + packages=['lamana', 'lamana.models', 'lamana.utils', 'lamana.tests', + 'lamana.tests.controls_LT'], keywords=['laminate analysis', 'visualization'], #install_requires=['matplotlib', 'pandas', 'numpy'], classifiers=[ From 4b841514a6d41a90c4a9e08a7d6bb2c17c617461 Mon Sep 17 00:00:00 2001 From: par2 Date: Fri, 27 Nov 2015 23:08:10 -0500 Subject: [PATCH 07/15] Add __init__ to subfolders --- lamana/models/tests/__init__.py | 0 lamana/tests/controls_LT/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 lamana/models/tests/__init__.py create mode 100644 lamana/tests/controls_LT/__init__.py diff --git a/lamana/models/tests/__init__.py b/lamana/models/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lamana/tests/controls_LT/__init__.py b/lamana/tests/controls_LT/__init__.py new file mode 100644 index 0000000..e69de29 From 4d57ff5932794e210ed67e9fe9f427fe208eb53f Mon Sep 17 00:00:00 2001 From: par2 Date: Fri, 27 Nov 2015 23:42:00 -0500 Subject: [PATCH 08/15] Add .csv files --- MANIFEST.in | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..e265adc --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include lamana/tests/controls_LT/*.csv diff --git a/setup.py b/setup.py index c144c26..bc8bea4 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ url='https://github.com/par2/lamana', # use the URL to the github repo download_url='https://github.com/par2/lamana/tarball/0.4.6', packages=['lamana', 'lamana.models', 'lamana.utils', 'lamana.tests', - 'lamana.tests.controls_LT'], + 'lamana.tests.controls_LT', 'lamana.models.tests'], keywords=['laminate analysis', 'visualization'], #install_requires=['matplotlib', 'pandas', 'numpy'], classifiers=[ From a8802f95f39d263657c60103da9f16d89d3f9f12 Mon Sep 17 00:00:00 2001 From: par2 Date: Sat, 28 Nov 2015 00:55:41 -0500 Subject: [PATCH 09/15] Fix mixed slashes in path --- lamana/tests/test_controls.py | 94 ++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/lamana/tests/test_controls.py b/lamana/tests/test_controls.py index ace75c3..38400d7 100644 --- a/lamana/tests/test_controls.py +++ b/lamana/tests/test_controls.py @@ -5,7 +5,7 @@ import numpy as np import pandas as pd -import nose.tools as nt +import nose.tools as nt import lamana as la import lamana.utils.tools as ut @@ -17,21 +17,21 @@ # SETUP ----------------------------------------------------------------------- def fix_discontinuities(laminate, inner_i): '''Replace t_ Nan values at discontinuities with adjacent value for inner_i. - + Accounts for the following found in controls directory: - missing t(um) and d(mm) columns - discontinuities in multi and special plies - and more ... - + ''' df = laminate.copy() # Tensile side - discTensidx = df.loc[(df['label'] == 'discont.') + discTensidx = df.loc[(df['label'] == 'discont.') & (df['type'] == 'inner') & (df['side'] == 'Tens.'), 't(um)'].index.tolist() # Compressive side - discCompidx = df.loc[(df['label'] == 'discont.') + discCompidx = df.loc[(df['label'] == 'discont.') & (df['type'] == 'inner') & (df['side'] == 'Comp.'), 't(um)'].index.tolist() #print(discTensidx) @@ -49,13 +49,13 @@ def fix_discontinuities(laminate, inner_i): def extract_dataframe(df): '''Parse corrected DataFrame from a csv file; legacy, automated or custom.''' df_expected = df.copy() - + # Mild cleanup if 'd(mm)' in df_expected.columns: df_expected['d(m)'] = df_expected['d(mm)']/1000. del df_expected['d(mm)'] - if 't(um)' not in df_expected.columns: # for custom controls from legacy scripts + if 't(um)' not in df_expected.columns: # for custom controls from legacy scripts df_expected['t(um)'] = df_expected['h(m)']/1e-6 # Assign Nan to layer thickness of the discontinuity row df_expected.loc[df_expected['label'] == 'discont.', 't(um)' @@ -64,18 +64,18 @@ def extract_dataframe(df): df_expected.loc[df_expected['type'] == 'middle', 't(um)' ] = df_expected.loc[df_expected['type'] == 'middle', 'h(m)'].multiply(2)/1e-6 - # Parse data mainly for the Case + # Parse data mainly for the Case nplies = len(df_expected['layer'].unique()) p = df_expected.groupby('layer').size().iloc[0] t_total = df_expected.iloc[-1]['d(m)'] # (in m) - # Get a geometry string to feed the API + # Get a geometry string to feed the API if nplies < 5: geometry = ut.get_special_geometry(df_expected) elif nplies >= 5: geometry = ut.get_multi_geometry(df_expected) elif nplies < 1: - raise Exception('Number of plies < 1. No plies detected.') + raise Exception('Number of plies < 1. No plies detected.') #print(geometry) # Plugin holes; overwrite placeholder Nans at discontinuities @@ -88,7 +88,7 @@ def extract_dataframe(df): '''Why is float needed here and not int?''' '''Getting 200L error for float.''' #print(inners) - inner_i = [float(t) for t in inners] + inner_i = [float(t) for t in inners] else: inner_i = float(geo[1]) #print(inner_i) @@ -96,42 +96,43 @@ def extract_dataframe(df): & (df_expected['type'] == 'outer'),'t(um)'] = outer if ('discont.' in df_expected['label'].values) and ('inner' in df_expected['type'].values): df_expected = fix_discontinuities(df_expected, inner_i) - + return df_expected, geometry, nplies, p, t_total # TESTS ----------------------------------------------------------------------- # Test Columns def test_apply_LaminateModels_cols_dimensions1(): - '''Test actual against expected DataFrames in .cvs files found in + '''Test actual against expected DataFrames in .cvs files found in tests/controls_LT; IDs and dimensional columns. - + ''' # Prepare file path. # Depends which directory nosetests is rum - path = os.getcwd() # use for the test in the correct path + #path = os.getcwd() # use for the test in the correct path #path = path + r'\lamana\tests\controls_LT' # for Main Script. Comment out in tests - path = path + r'\tests\controls_LT' # for test - #path = path + r'\controls_LT' # for test + #path = path + r'\tests\controls_LT' # for test + path = os.path.join(os.getcwd(), 'tests', 'controls_LT')# for test + #path = path + r'\controls_LT' # for test # Read all files in the path (REF 013) for file in ut.read_csv_dir(path): #df_expected = file df = file #print(df_expected) - + df_expected, geometry, nplies, p, t_total = extract_dataframe(df) - + # Build actual Case using distributions API dft.load_params['p'] = p - case = la.distributions.Case(dft.load_params, dft.mat_props) - case.apply([geometry]) + case = la.distributions.Case(dft.load_params, dft.mat_props) + case.apply([geometry]) df = case.frames[0] # Compare the dimensional columns only '''Bypassing z(m), z(m)*, intf and k for now''' '''UPDATE: k add back in 0.4.4b''' ### - cols = ['layer', 'side','type', 'matl', + cols = ['layer', 'side','type', 'matl', # 'label', 't(um)', 'h(m)', 'd(m)', 'intf', 'k', 'Z(m)', 'z(m)'] # 'label', 't(um)', 'h(m)', 'd(m)', 'intf', 'k', 'Z(m)', ] # 'label', 't(um)', 'h(m)', 'd(m)', 'intf', 'Z(m)', ] # removed; k redefined in 0.4.3c4d @@ -143,25 +144,25 @@ def test_apply_LaminateModels_cols_dimensions1(): actual = df[cols] expected = df_expected[cols] - #print ('expected (file) \n', expected) + #print ('expected (file) \n', expected) #print('actual (API) \n', actual) #print(expected.dtypes) #print(actual.dtypes) print('\n') ut.assertFrameEqual(actual, expected) - + def test_apply_LaminateModels_cols_models1(): '''Test .cvs files found in tests/controls_LT with API DataFrames. - Comparing models columns only. - + Comparing models columns only. + Due to a different algorithms for calculating internal values, rows yielding maximum and minimum stress are the most reliable comparisons. - - Tests for internal points can varying depending on choice of z(m). + + Tests for internal points can varying depending on choice of z(m). So they will be excluded from this test. ''' '''Wait for skipcols kwarg in read_csv in pandas 0.17''' - + def remove_units(cols): '''Return a dict of stress column lables with units removed.''' #cols = cols.tolist() @@ -173,28 +174,29 @@ def remove_units(cols): #print(name) dict_[colname] = unitless_name return dict_ - + # Prepare file path. # Depends which directory nosetests is rum - path = os.getcwd() # use for the test in the correct path + #path = os.getcwd() # use for the test in the correct path #path = path + r'\lamana\tests\controls_LT' # for Main Script. Comment out in tests - path = path + r'\tests\controls_LT' # for test - #path = path + r'\controls_LT' # for test + #path = path + r'\tests\controls_LT' # for test + path = os.path.join(os.getcwd(), 'tests', 'controls_LT')# for test + #path = path + r'\controls_LT' # for test # Read all files in the path (REF 013) for file in ut.read_csv_dir(path): #df_expected = file df = file #print(df_expected) - + df_expected, geometry, nplies, p, t_total = extract_dataframe(df) - + # Build actual Case using distributions API dft.load_params['p'] = p - case = la.distributions.Case(dft.load_params, dft.mat_props) - case.apply([geometry]) + case = la.distributions.Case(dft.load_params, dft.mat_props) + case.apply([geometry]) df = case.frames[0] - + # Compare only model-related columns; skip API columns IDs = ['layer','side', 'type', 'matl', 't(um)'] # except label_ Dimensionals = ['h(m)', 'd(m)', 'intf', 'k', 'Z(m)', 'z(m)', 'z(m)*'] @@ -202,14 +204,14 @@ def remove_units(cols): skippedcols = IDs + Dimensionals actual_remainingcols = df.columns.difference(skippedcols) expected_remainingcols = df_expected.columns.difference(skippedcols) - + # Get model columns only and strip units from stress columns df_models = df[actual_remainingcols].copy() df_expected = df_expected[expected_remainingcols].copy() df_models.rename(columns=remove_units(actual_remainingcols), inplace=True) df_expected.rename(columns=remove_units(expected_remainingcols), inplace=True) #print(df_expected) - + print('A .csv file is being processed with the following dimensional properties:') print(' Number of plies: {} \n p: {} \n total \ t (m): {} \n geometry: {} \n'.format(nplies, p, t_total, geometry)) @@ -217,7 +219,7 @@ def remove_units(cols): # Use all rows (including internals, optional) #actual = df_models #expected = df_expected[expected_remainingcols] - + # Only use max stress rows (interfacial) actual1 = df_models.loc[df_models['label'] == 'interface'] expected1 = df_expected.loc[df_expected['label'] == 'interface'] @@ -229,9 +231,9 @@ def remove_units(cols): expected2 = df_expected.loc[df_expected['label'] == 'discont.'] #expected2 = df_expected[expected_remainingcols].loc[df_expected['label'] == 'discont.'] - #print ('expected (file) \n', expected1) + #print ('expected (file) \n', expected1) #print('actual (API) \n', actual1) - #print ('expected (file) \n', expected2) + #print ('expected (file) \n', expected2) #print('actual (API) \n', actual2) #print(type(expected1)) #print(type(actual1)) @@ -240,6 +242,6 @@ def remove_units(cols): print('\n') ut.assertFrameEqual(actual1, expected1, check_dtype=False) # max stress rows if p > 1: # min stress rows - ut.assertFrameEqual(actual2, expected2, check_dtype=False) - - # Internal rows depend on the `z_` algorithm. They are not compared to prevent breakage. \ No newline at end of file + ut.assertFrameEqual(actual2, expected2, check_dtype=False) + + # Internal rows depend on the `z_` algorithm. They are not compared to prevent breakage. From 7323de89dcc706a192fd84182d87fee26e4818ce Mon Sep 17 00:00:00 2001 From: par2 Date: Sat, 28 Nov 2015 02:07:49 -0500 Subject: [PATCH 10/15] Fix test directory path --- lamana/tests/test_controls.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lamana/tests/test_controls.py b/lamana/tests/test_controls.py index 38400d7..d3f6e57 100644 --- a/lamana/tests/test_controls.py +++ b/lamana/tests/test_controls.py @@ -109,9 +109,10 @@ def test_apply_LaminateModels_cols_dimensions1(): # Prepare file path. # Depends which directory nosetests is rum #path = os.getcwd() # use for the test in the correct path + path = os.path.join(os.getcwd(), 'lamana', 'tests', 'controls_LT') # for builds #path = path + r'\lamana\tests\controls_LT' # for Main Script. Comment out in tests #path = path + r'\tests\controls_LT' # for test - path = os.path.join(os.getcwd(), 'tests', 'controls_LT')# for test + #path = os.path.join(os.getcwd(), 'tests', 'controls_LT') # for test #path = path + r'\controls_LT' # for test # Read all files in the path (REF 013) @@ -178,9 +179,10 @@ def remove_units(cols): # Prepare file path. # Depends which directory nosetests is rum #path = os.getcwd() # use for the test in the correct path + path = os.path.join(os.getcwd(), 'lamana', 'tests', 'controls_LT') # for builds #path = path + r'\lamana\tests\controls_LT' # for Main Script. Comment out in tests #path = path + r'\tests\controls_LT' # for test - path = os.path.join(os.getcwd(), 'tests', 'controls_LT')# for test + #path = os.path.join(os.getcwd(), 'tests', 'controls_LT') # for test #path = path + r'\controls_LT' # for test # Read all files in the path (REF 013) From da0534bebbd8ba7832358c34878e1b4eb90db319 Mon Sep 17 00:00:00 2001 From: par2 Date: Sat, 28 Nov 2015 02:38:12 -0500 Subject: [PATCH 11/15] Removed non .csv files --- lamana/tests/controls_LT/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 lamana/tests/controls_LT/__init__.py diff --git a/lamana/tests/controls_LT/__init__.py b/lamana/tests/controls_LT/__init__.py deleted file mode 100644 index e69de29..0000000 From 8d234e93c32e0fc625875683debbdaa2f76e433c Mon Sep 17 00:00:00 2001 From: par2 Date: Sat, 28 Nov 2015 03:04:43 -0500 Subject: [PATCH 12/15] Add py2.7 and later versions to yml --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8a9527..225424e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,9 @@ language: python python: -# - "2.7" -# - "3.3" + - "2.7" - "3.4" -# - "3.5" -# - "3.5-dev" # 3.5 development branch + - "3.5" + - "3.5-dev" # 3.5 development branch # command to install dependencies install: "pip install -r requirements.txt" # command to run tests From bd0a23cec995b4dd22f4a60a8a6fffe6492dd071 Mon Sep 17 00:00:00 2001 From: par2 Date: Sat, 28 Nov 2015 03:26:01 -0500 Subject: [PATCH 13/15] Remove 3.5-dev from yml Numpy fails in 3.5.1rc1. Added 3.3. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 225424e..9d6935c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ language: python python: - "2.7" + - "3.3" - "3.4" - "3.5" - - "3.5-dev" # 3.5 development branch +# - "3.5-dev" # 3.5 development branch # command to install dependencies install: "pip install -r requirements.txt" # command to run tests From 8cf74705cc62d17faf7c25a2f190a4e60cc94af5 Mon Sep 17 00:00:00 2001 From: par2 Date: Sat, 28 Nov 2015 03:30:49 -0500 Subject: [PATCH 14/15] Initial README Test Build status button --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..6d865d5 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +[![Build Status](https://travis-ci.org/par2/lamana-test.svg?branch=develop)](https://travis-ci.org/par2/lamana-test) From 5ffaf734963357843ac4a61ee365e9e67dcd13ae Mon Sep 17 00:00:00 2001 From: par2 Date: Sat, 28 Nov 2015 13:48:13 -0500 Subject: [PATCH 15/15] Merge bump and first build pass. --- lamana/__init__.py | 2 +- setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lamana/__init__.py b/lamana/__init__.py index a5ae8fd..5089c8f 100644 --- a/lamana/__init__.py +++ b/lamana/__init__.py @@ -1,7 +1,7 @@ # ----------------------------------------------------------------------------- __title__ = 'lamana' -__version__ = '0.4.6' +__version__ = '0.4.7' __author__ = 'P. Robinson II' __license__ = 'BSD3' __copyright__ = 'Copyright 2015 P. Robinson II' diff --git a/setup.py b/setup.py index bc8bea4..3faaabe 100644 --- a/setup.py +++ b/setup.py @@ -2,12 +2,12 @@ setup( name='lamana', - version='0.4.6', ### edit + version='0.4.7', ### edit description='An extensible Python package for Laminate Analysis.', author='P. Robinson II', author_email='par2.get@gmail.com', url='https://github.com/par2/lamana', # use the URL to the github repo - download_url='https://github.com/par2/lamana/tarball/0.4.6', + download_url='https://github.com/par2/lamana/tarball/0.4.7', packages=['lamana', 'lamana.models', 'lamana.utils', 'lamana.tests', 'lamana.tests.controls_LT', 'lamana.models.tests'], keywords=['laminate analysis', 'visualization'],