From 16b84ce5de365008865417904b0bde0acb8b6912 Mon Sep 17 00:00:00 2001 From: David Pugh Date: Thu, 8 Nov 2018 16:15:57 +0000 Subject: [PATCH 01/10] Updating appveyor tag build --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1176176..76c9492 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,8 +49,8 @@ after_test: # Again, you only need if you're building C extensions for # 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct # interpreter - - cmd: if(%APPVEYOR_REPO_TAG% == 'True') %PYTHON%\\python.exe setup.py bdist_wheel ELSE echo "Not building because this is not a tag build" - - ps: if($env:APPVEYOR_REPO_TAG -eq 'True') {ls dist} + - cmd: IF %APPVEYOR_REPO_TAG% == 'True' (%PYTHON%\\python.exe setup.py bdist_wheel) ELSE (echo Not building because this is not a tag build) + - ps: if ($env:APPVEYOR_REPO_TAG -eq 'True') {ls dist} artifacts: # bdist_wheel puts your built wheel in the dist directory - path: dist\* From d5cb8053cb8239668365e7bab806b8afcf38f57f Mon Sep 17 00:00:00 2001 From: David Pugh Date: Thu, 8 Nov 2018 18:20:04 +0000 Subject: [PATCH 02/10] Changing travis to only build gh pages on full release --- .travis.yml | 2 +- appveyor.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39f50fd..7d425f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ stages: - name: build if: tag IS present - name: gh-pages - if: tag =~ ^\d+\.\d+\.\d+ + if: tag =~ ^\d+\.\d+\.\d+$ script: skip jobs: fast_finish: true diff --git a/appveyor.yml b/appveyor.yml index 76c9492..9324977 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,6 +25,7 @@ environment: install: # We need wheel installed to build wheels + - ps: Get-ChildItem Env - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" build: off From e4d576e1671d18eb400c0be2de187eea5e3be1e9 Mon Sep 17 00:00:00 2001 From: David Pugh Date: Thu, 8 Nov 2018 18:24:46 +0000 Subject: [PATCH 03/10] Debugging appveyor --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 9324977..86155f2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,7 +25,7 @@ environment: install: # We need wheel installed to build wheels - - ps: Get-ChildItem Env + - ps: Get-ChildItem Env: - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" build: off From 2b0afaa7422bd01123b47fdecc021a2a40d79a46 Mon Sep 17 00:00:00 2001 From: David Pugh Date: Thu, 8 Nov 2018 18:29:57 +0000 Subject: [PATCH 04/10] Updating appveyor.yml --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 86155f2..dfd178a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,7 +25,7 @@ environment: install: # We need wheel installed to build wheels - - ps: Get-ChildItem Env: + - ps: "Get-ChildItem Env:" - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" build: off From 41643fec6545787cd85d3539c89d165da019d5a9 Mon Sep 17 00:00:00 2001 From: David Pugh Date: Thu, 8 Nov 2018 18:40:57 +0000 Subject: [PATCH 05/10] Setting up 3 build projects --- appveyor.yml => appveyor-py27.yml | 17 ------------ appveyor-py35.yaml | 45 +++++++++++++++++++++++++++++++ appveyor-py36.yml | 45 +++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 17 deletions(-) rename appveyor.yml => appveyor-py27.yml (73%) create mode 100644 appveyor-py35.yaml create mode 100644 appveyor-py36.yml diff --git a/appveyor.yml b/appveyor-py27.yml similarity index 73% rename from appveyor.yml rename to appveyor-py27.yml index dfd178a..f5f65af 100644 --- a/appveyor.yml +++ b/appveyor-py27.yml @@ -1,31 +1,14 @@ environment: matrix: - - # For Python versions available on Appveyor, see - # http://www.appveyor.com/docs/installed-software#python - # The list here is complete (excluding Python 2.6, which - # isn't covered by this document) at the time of writing. - - PYTHON: "C:\\Python27-x64" PYTHON_EXE: "C:\\Python27-x64\\python.exe" TOXENV: 'test-py27' MPLBACKEND: 'Agg' PATH: "C:\\Python27-x64;$(PATH)" - - PYTHON: "C:\\Python35-x64" - PYTHON_EXE: "C:\\Python35-x64\\python.exe" - TOXENV: 'test-py35' - MPLBACKEND: 'Agg' - PATH: "C:\\Python35-x64;$(PATH)" - - PYTHON: "C:\\Python36-x64" - PYTHON_EXE: "C:\\Python36-x64\\python.exe" - TOXENV: 'test-py36' - MPLBACKEND: 'Agg' - PATH: "C:\\Python36-x64;$(PATH)" install: # We need wheel installed to build wheels - - ps: "Get-ChildItem Env:" - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" build: off diff --git a/appveyor-py35.yaml b/appveyor-py35.yaml new file mode 100644 index 0000000..358af4a --- /dev/null +++ b/appveyor-py35.yaml @@ -0,0 +1,45 @@ +environment: + + matrix: + - PYTHON: "C:\\Python35-x64" + PYTHON_EXE: "C:\\Python35-x64\\python.exe" + TOXENV: 'test-py35' + MPLBACKEND: 'Agg' + PATH: "C:\\Python35-x64;$(PATH)" + +install: + # We need wheel installed to build wheels + - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" + +build: off + +before_test: + - cmd: "%PYTHON%\\python.exe setup.py build_ext" + +test_script: + # Put your test command here. + # If you don't need to build C extensions on 64-bit Python 3.3 or 3.4, + # you can remove "build.cmd" from the front of the command, as it's + # only needed to support those cases. + # Note that you must use the environment variable %PYTHON% to refer to + # the interpreter you're using - Appveyor does not do anything special + # to put the Python version you want to use on PATH. + - cmd: echo %PATH% + - cmd: SET PATH=%PYTHON%;%PATH% + - cmd: "%PYTHON%\\Scripts\\tox --skip-missing-interpreters" + +after_test: + # This step builds your wheels. + # Again, you only need if you're building C extensions for + # 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct + # interpreter + - cmd: IF %APPVEYOR_REPO_TAG% == 'True' (%PYTHON%\\python.exe setup.py bdist_wheel) ELSE (echo Not building because this is not a tag build) + - ps: if ($env:APPVEYOR_REPO_TAG -eq 'True') {ls dist} +artifacts: + # bdist_wheel puts your built wheel in the dist directory + - path: dist\* + +#on_success: +# You can use this step to upload your artifacts to a public website. +# See Appveyor's documentation for more details. Or you can simply +# access your wheels from the Appveyor "artifacts" tab for your build. \ No newline at end of file diff --git a/appveyor-py36.yml b/appveyor-py36.yml new file mode 100644 index 0000000..78c99dd --- /dev/null +++ b/appveyor-py36.yml @@ -0,0 +1,45 @@ +environment: + + matrix: + - PYTHON: "C:\\Python36-x64" + PYTHON_EXE: "C:\\Python36-x64\\python.exe" + TOXENV: 'test-py36' + MPLBACKEND: 'Agg' + PATH: "C:\\Python36-x64;$(PATH)" + +install: + # We need wheel installed to build wheels + - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" + +build: off + +before_test: + - cmd: "%PYTHON%\\python.exe setup.py build_ext" + +test_script: + # Put your test command here. + # If you don't need to build C extensions on 64-bit Python 3.3 or 3.4, + # you can remove "build.cmd" from the front of the command, as it's + # only needed to support those cases. + # Note that you must use the environment variable %PYTHON% to refer to + # the interpreter you're using - Appveyor does not do anything special + # to put the Python version you want to use on PATH. + - cmd: echo %PATH% + - cmd: SET PATH=%PYTHON%;%PATH% + - cmd: "%PYTHON%\\Scripts\\tox --skip-missing-interpreters" + +after_test: + # This step builds your wheels. + # Again, you only need if you're building C extensions for + # 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct + # interpreter + - cmd: IF %APPVEYOR_REPO_TAG% == 'True' (%PYTHON%\\python.exe setup.py bdist_wheel) ELSE (echo Not building because this is not a tag build) + - ps: if ($env:APPVEYOR_REPO_TAG -eq 'True') {ls dist} +artifacts: + # bdist_wheel puts your built wheel in the dist directory + - path: dist\* + +#on_success: +# You can use this step to upload your artifacts to a public website. +# See Appveyor's documentation for more details. Or you can simply +# access your wheels from the Appveyor "artifacts" tab for your build. \ No newline at end of file From f83f6ed91ad814fc19e6e5ee53b15adccefb01d2 Mon Sep 17 00:00:00 2001 From: David Pugh Date: Thu, 8 Nov 2018 18:50:38 +0000 Subject: [PATCH 06/10] Revert "Setting up 3 build projects" This reverts commit 41643fec6545787cd85d3539c89d165da019d5a9. --- appveyor-py35.yaml | 45 ------------------------------- appveyor-py36.yml | 45 ------------------------------- appveyor-py27.yml => appveyor.yml | 17 ++++++++++++ 3 files changed, 17 insertions(+), 90 deletions(-) delete mode 100644 appveyor-py35.yaml delete mode 100644 appveyor-py36.yml rename appveyor-py27.yml => appveyor.yml (73%) diff --git a/appveyor-py35.yaml b/appveyor-py35.yaml deleted file mode 100644 index 358af4a..0000000 --- a/appveyor-py35.yaml +++ /dev/null @@ -1,45 +0,0 @@ -environment: - - matrix: - - PYTHON: "C:\\Python35-x64" - PYTHON_EXE: "C:\\Python35-x64\\python.exe" - TOXENV: 'test-py35' - MPLBACKEND: 'Agg' - PATH: "C:\\Python35-x64;$(PATH)" - -install: - # We need wheel installed to build wheels - - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" - -build: off - -before_test: - - cmd: "%PYTHON%\\python.exe setup.py build_ext" - -test_script: - # Put your test command here. - # If you don't need to build C extensions on 64-bit Python 3.3 or 3.4, - # you can remove "build.cmd" from the front of the command, as it's - # only needed to support those cases. - # Note that you must use the environment variable %PYTHON% to refer to - # the interpreter you're using - Appveyor does not do anything special - # to put the Python version you want to use on PATH. - - cmd: echo %PATH% - - cmd: SET PATH=%PYTHON%;%PATH% - - cmd: "%PYTHON%\\Scripts\\tox --skip-missing-interpreters" - -after_test: - # This step builds your wheels. - # Again, you only need if you're building C extensions for - # 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct - # interpreter - - cmd: IF %APPVEYOR_REPO_TAG% == 'True' (%PYTHON%\\python.exe setup.py bdist_wheel) ELSE (echo Not building because this is not a tag build) - - ps: if ($env:APPVEYOR_REPO_TAG -eq 'True') {ls dist} -artifacts: - # bdist_wheel puts your built wheel in the dist directory - - path: dist\* - -#on_success: -# You can use this step to upload your artifacts to a public website. -# See Appveyor's documentation for more details. Or you can simply -# access your wheels from the Appveyor "artifacts" tab for your build. \ No newline at end of file diff --git a/appveyor-py36.yml b/appveyor-py36.yml deleted file mode 100644 index 78c99dd..0000000 --- a/appveyor-py36.yml +++ /dev/null @@ -1,45 +0,0 @@ -environment: - - matrix: - - PYTHON: "C:\\Python36-x64" - PYTHON_EXE: "C:\\Python36-x64\\python.exe" - TOXENV: 'test-py36' - MPLBACKEND: 'Agg' - PATH: "C:\\Python36-x64;$(PATH)" - -install: - # We need wheel installed to build wheels - - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" - -build: off - -before_test: - - cmd: "%PYTHON%\\python.exe setup.py build_ext" - -test_script: - # Put your test command here. - # If you don't need to build C extensions on 64-bit Python 3.3 or 3.4, - # you can remove "build.cmd" from the front of the command, as it's - # only needed to support those cases. - # Note that you must use the environment variable %PYTHON% to refer to - # the interpreter you're using - Appveyor does not do anything special - # to put the Python version you want to use on PATH. - - cmd: echo %PATH% - - cmd: SET PATH=%PYTHON%;%PATH% - - cmd: "%PYTHON%\\Scripts\\tox --skip-missing-interpreters" - -after_test: - # This step builds your wheels. - # Again, you only need if you're building C extensions for - # 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct - # interpreter - - cmd: IF %APPVEYOR_REPO_TAG% == 'True' (%PYTHON%\\python.exe setup.py bdist_wheel) ELSE (echo Not building because this is not a tag build) - - ps: if ($env:APPVEYOR_REPO_TAG -eq 'True') {ls dist} -artifacts: - # bdist_wheel puts your built wheel in the dist directory - - path: dist\* - -#on_success: -# You can use this step to upload your artifacts to a public website. -# See Appveyor's documentation for more details. Or you can simply -# access your wheels from the Appveyor "artifacts" tab for your build. \ No newline at end of file diff --git a/appveyor-py27.yml b/appveyor.yml similarity index 73% rename from appveyor-py27.yml rename to appveyor.yml index f5f65af..dfd178a 100644 --- a/appveyor-py27.yml +++ b/appveyor.yml @@ -1,14 +1,31 @@ environment: matrix: + + # For Python versions available on Appveyor, see + # http://www.appveyor.com/docs/installed-software#python + # The list here is complete (excluding Python 2.6, which + # isn't covered by this document) at the time of writing. + - PYTHON: "C:\\Python27-x64" PYTHON_EXE: "C:\\Python27-x64\\python.exe" TOXENV: 'test-py27' MPLBACKEND: 'Agg' PATH: "C:\\Python27-x64;$(PATH)" + - PYTHON: "C:\\Python35-x64" + PYTHON_EXE: "C:\\Python35-x64\\python.exe" + TOXENV: 'test-py35' + MPLBACKEND: 'Agg' + PATH: "C:\\Python35-x64;$(PATH)" + - PYTHON: "C:\\Python36-x64" + PYTHON_EXE: "C:\\Python36-x64\\python.exe" + TOXENV: 'test-py36' + MPLBACKEND: 'Agg' + PATH: "C:\\Python36-x64;$(PATH)" install: # We need wheel installed to build wheels + - ps: "Get-ChildItem Env:" - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" build: off From ec0902ecca203fb01702c8366786279752b6aa8b Mon Sep 17 00:00:00 2001 From: David Pugh Date: Thu, 8 Nov 2018 18:51:20 +0000 Subject: [PATCH 07/10] Reverting to one appveyor project --- ci/travis_appveyor_build.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ci/travis_appveyor_build.py b/ci/travis_appveyor_build.py index bc2531e..f655d4c 100644 --- a/ci/travis_appveyor_build.py +++ b/ci/travis_appveyor_build.py @@ -45,7 +45,11 @@ def update_job(self, job_id, job_status): 'commitID': os.getenv('TRAVIS_COMMIT') } r = requests.post(api_url + '/builds', payload, headers=headers) -r.raise_for_status() +try: + r.raise_for_status() +except Exception as e: + print(r.content) + raise e build = r.json() print('Started AppVeyor build (buildId={buildId}, version={version})'.format(**build), flush=True) log = Log() From 02c567d14da69caee9d443744ade3b711ef444ce Mon Sep 17 00:00:00 2001 From: David Pugh Date: Thu, 8 Nov 2018 21:15:34 +0000 Subject: [PATCH 08/10] Speeding up tests --- appveyor.yml | 1 - src/MTfit/tests/unit/test_inversion.py | 34 +++++++++++++------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index dfd178a..76c9492 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,7 +25,6 @@ environment: install: # We need wheel installed to build wheels - - ps: "Get-ChildItem Env:" - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" build: off diff --git a/src/MTfit/tests/unit/test_inversion.py b/src/MTfit/tests/unit/test_inversion.py index 5df65ce..b9be510 100644 --- a/src/MTfit/tests/unit/test_inversion.py +++ b/src/MTfit/tests/unit/test_inversion.py @@ -1313,7 +1313,7 @@ def test__recover_test(self): algorithm='Time', parallel=self.parallel, phy_mem=1, max_time=10, convert=False) self.inversion.number_samples = 100 self.assertFalse(len(self.inversion.algorithm.pdf_sample)) - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion.forward() self.assertTrue(self.inversion.algorithm.pdf_sample.n, str( self.inversion.algorithm.pdf_sample.n)) @@ -1412,7 +1412,7 @@ def test_forward(self): algorithm='Time', parallel=self.parallel, phy_mem=0.1, n=2, max_time=10, convert=False) self.inversion.number_samples = 100 self.assertFalse(len(self.inversion.algorithm.pdf_sample)) - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion.forward() self.assertTrue(self.inversion.algorithm.pdf_sample.n, str( self.inversion.algorithm.pdf_sample.n)) @@ -1423,7 +1423,7 @@ def test_forward(self): 'Measured': np.matrix([[1], [-1], [-1]]), 'Error': np.matrix([[0.001], [0.5], [0.02]])}}, algorithm='Time', parallel=self.parallel, phy_mem=0.1, n=2, max_time=10, convert=False) self.inversion.location_pdf_files = ['test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion.forward() try: os.remove('test.scatangle') @@ -1438,7 +1438,7 @@ def test__random_sampling_forward(self): algorithm='Time', parallel=self.parallel, phy_mem=0.1, n=2, max_time=10, convert=False) self.inversion.number_samples = 100 self.assertFalse(len(self.inversion.algorithm.pdf_sample)) - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion._random_sampling_forward() self.assertTrue(self.inversion.algorithm.pdf_sample.n, str( self.inversion.algorithm.pdf_sample.n)) @@ -1450,7 +1450,7 @@ def test__random_sampling_forward(self): 'Measured': np.matrix([[1], [-1], [-1]]), 'Error': np.matrix([[0.001], [0.5], [0.02]])}}, algorithm='Time', parallel=self.parallel, phy_mem=0.1, n=2, max_time=10, convert=False) self.inversion.location_pdf_files = ['test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion._random_sampling_forward() try: os.remove('test.scatangle') @@ -1465,7 +1465,7 @@ def test__random_sampling_multiple_forward(self): self.inversion = Inversion([data, data], multiple_events=True, algorithm='Time', parallel=self.parallel, phy_mem=0.1, n=2, max_time=10, convert=False) self.inversion.number_samples = 100 self.assertFalse(len(self.inversion.algorithm.pdf_sample)) - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion._random_sampling_multiple_forward() self.assertTrue(self.inversion.algorithm.pdf_sample.n, str( self.inversion.algorithm.pdf_sample.n)) @@ -1475,7 +1475,7 @@ def test__random_sampling_multiple_forward(self): f.write(self.station_angles()) self.inversion = Inversion([data, data], multiple_events=True, algorithm='Time', parallel=self.parallel, phy_mem=0.1, n=2, max_time=10, convert=False) self.inversion.location_pdf_files = ['test.scatangle', 'test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion._random_sampling_multiple_forward() try: os.remove('test.scatangle') @@ -1490,7 +1490,7 @@ def test__random_sampling_multiple_forward(self): self.inversion = Inversion([data, data], multiple_events=True, algorithm='Time', parallel=self.parallel, phy_mem=0.1, n=2, max_time=10, relative_amplitude=True, convert=False) self.inversion.number_samples = 100 self.assertFalse(len(self.inversion.algorithm.pdf_sample)) - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion._random_sampling_multiple_forward() self.assertTrue(self.inversion.algorithm.pdf_sample.n, str(self.inversion.algorithm.pdf_sample.n)) self.inversion._close_pool() @@ -1499,7 +1499,7 @@ def test__random_sampling_multiple_forward(self): f.write(self.station_angles()) self.inversion = Inversion([data, data], multiple_events=True, algorithm='Time', parallel=self.parallel, phy_mem=0.1, n=2, max_time=10, relative_amplitude=True, convert=False) self.inversion.location_pdf_files = ['test.scatangle', 'test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion._random_sampling_multiple_forward() try: os.remove('test.scatangle') @@ -1522,7 +1522,7 @@ def test__mcmc_forward(self): algorithm='McMC', parallel=False, learning_length=10, chain_length=100, acceptance_rate_window=5, phy_mem=1, convert=False) self.inversion.number_samples = 100 self.assertFalse(len(self.inversion.algorithm.pdf_sample)) - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion._mcmc_forward() self.assertTrue(os.path.exists('TestAMT.mat')) try: @@ -1537,7 +1537,7 @@ def test__mcmc_forward(self): 'Measured': np.matrix([[1], [-1], [-1]]), 'Error': np.matrix([[0.001], [0.5], [0.02]])}}, algorithm='Time', parallel=False, learning_length=10, chain_length=100, acceptance_rate_window=5, phy_mem=1, max_time=10, convert=False) self.inversion.location_pdf_files = ['test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion._mcmc_forward() self.assertTrue(os.path.exists('TestAMT.mat')) try: @@ -1580,7 +1580,7 @@ def test__mcmc_multiple_forward_location_uncertainty(self): with open('test.scatangle', 'w') as f: f.write(self.station_angles()) self.inversion.location_pdf_files = ['test.scatangle', 'test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion._mcmc_multiple_forward() try: os.remove('test.scatangle') @@ -1629,7 +1629,7 @@ def test__mcmc_multiple_forward_amplitude_location_uncertainty(self): with open('test.scatangle', 'w') as f: f.write(self.station_angles()) self.inversion.location_pdf_files = ['test.scatangle', 'test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion._mcmc_multiple_forward() try: os.remove('test.scatangle') @@ -1649,7 +1649,7 @@ def test__MATLAB_output(self): 'Measured': np.matrix([[1], [-1], [-1]]), 'Error': np.matrix([[0.001], [0.001], [0.002]])}}, algorithm='Time', parallel=self.parallel, phy_mem=1, max_time=10, convert=False) self.inversion.location_pdf_files = ['test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion.forward() try: os.remove('test.scatangle') @@ -1669,7 +1669,7 @@ def test__pickle_output(self): 'Measured': np.matrix([[1], [-1], [-1]]), 'Error': np.matrix([[0.001], [0.001], [0.002]])}}, algorithm='Time', parallel=self.parallel, phy_mem=1, max_time=10, output_format='pickle', convert=False) self.inversion.location_pdf_files = ['test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion.forward() try: os.remove('test.scatangle') @@ -1716,7 +1716,7 @@ def test_recover(self): 'Measured': np.matrix([[1], [-1], [-1]]), 'Error': np.matrix([[0.1], [0.1], [0.2]])}}, algorithm='Time', parallel=self.parallel, phy_mem=1, max_time=10, convert=False) self.inversion.location_pdf_files = ['test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion.forward() try: os.remove('test.scatangle') @@ -1732,7 +1732,7 @@ def test_recover(self): 'Measured': np.matrix([[1], [-1], [-1]]), 'Error': np.matrix([[0.001], [0.001], [0.02]])}}, algorithm='Time', recover=True, parallel=self.parallel, phy_mem=1, max_time=10, convert=False) self.inversion.location_pdf_files = ['test.scatangle'] - self.inversion.algorithm.max_time = 10 + self.inversion.algorithm.max_time = 5 self.inversion.forward() # LOG FILE NOT DELETING try: From 6f2a31ff3f9a3cfb587545cb27c13f1a0f17a243 Mon Sep 17 00:00:00 2001 From: David Pugh Date: Thu, 15 Nov 2018 10:47:42 +0000 Subject: [PATCH 09/10] Working on appveyor build step --- appveyor.yml | 4 ++-- ci/get_appveyor_wheels.py | 4 ++-- ci/get_version.py | 12 ++++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 ci/get_version.py diff --git a/appveyor.yml b/appveyor.yml index 76c9492..6f40136 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,8 +49,8 @@ after_test: # Again, you only need if you're building C extensions for # 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct # interpreter - - cmd: IF %APPVEYOR_REPO_TAG% == 'True' (%PYTHON%\\python.exe setup.py bdist_wheel) ELSE (echo Not building because this is not a tag build) - - ps: if ($env:APPVEYOR_REPO_TAG -eq 'True') {ls dist} + - ps: if ($(& $env:PYTHON_EXE .\ci\get_version.py) -ne '') {& $env:PYTHON_EXE setup.py bdist_wheel} ELSE {echo "Not building because this is not a tag build"} + - ps: if ($LAST_EXIT_CODE -eq 'True') {ls dist} artifacts: # bdist_wheel puts your built wheel in the dist directory - path: dist\* diff --git a/ci/get_appveyor_wheels.py b/ci/get_appveyor_wheels.py index 44b9ee4..d1f853b 100644 --- a/ci/get_appveyor_wheels.py +++ b/ci/get_appveyor_wheels.py @@ -46,8 +46,8 @@ r.raise_for_status() build = r.json() job_ids = [job['jobId'] for job in build['jobs']] -if not os.path.exists(os.path.join(REPO_PATH, 'dist')) -os.mkdir(os.path.join(REPO_PATH, 'dist')) +if not os.path.exists(os.path.join(REPO_PATH, 'dist')): + os.mkdir(os.path.join(REPO_PATH, 'dist')) for job_id in job_ids: r = requests.get('{}/buildjobs/{}/artifacts'.format(api_url, job_id), headers=headers) r.raise_for_status() diff --git a/ci/get_version.py b/ci/get_version.py new file mode 100644 index 0000000..520027c --- /dev/null +++ b/ci/get_version.py @@ -0,0 +1,12 @@ +import subprocess +import sys + +import pkg_resources + +version = pkg_resources.parse_version(subprocess.check_output([sys.executable, 'setup.py', '--version']).decode()) +if version.local: + print('') + sys.exit(1) +else: + print(version) + sys.exit(0) From 0164158b93f6a3496e82656704dad0c1dee3e426 Mon Sep 17 00:00:00 2001 From: David Pugh Date: Sun, 20 Jan 2019 17:47:00 +0000 Subject: [PATCH 10/10] Adding fix for expected Cython errors - closes #58 --- .travis.yml | 12 +++---- Pipfile | 1 - appveyor.yml | 10 +++--- .../algorithms/markov_chain_monte_carlo.py | 5 +-- src/MTfit/probability/probability.py | 36 ++++++++++--------- src/MTfit/sampling.py | 4 +-- 6 files changed, 36 insertions(+), 32 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d425f0..14c1791 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,11 +59,11 @@ jobs: script: tox -e test-py36 python: 3.6 name: Unit Tests - - stage: test - script: python ci/travis_appveyor_build.py - python: 3.6 - name: Unit Tests (Windows) - if: branch in (master, develop) OR tag IS present + # - stage: test + # script: python ci/travis_appveyor_build.py + # python: 3.6 + # name: Unit Tests (Windows) + # if: branch in (master, develop) OR tag IS present - stage: examples-test script: tox -e examples-py27 python: 2.7 @@ -79,7 +79,7 @@ jobs: - stage: build python: 3.6 name: Build - before_deploy: python ci/get_appveyor_wheels.py + # before_deploy: python ci/get_appveyor_wheels.py deploy: - provider: pypi user: "$PYPI_USERNAME" diff --git a/Pipfile b/Pipfile index 0f5cd30..df850c7 100644 --- a/Pipfile +++ b/Pipfile @@ -9,4 +9,3 @@ scipy = "==1.0.0" matplotlib = "==2.1.0" [dev-packages] - diff --git a/appveyor.yml b/appveyor.yml index 6f40136..ece1b19 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,7 +25,7 @@ environment: install: # We need wheel installed to build wheels - - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython" + - cmd: "%PYTHON%\\python.exe -m pip install wheel tox numpy cython twine" build: off @@ -50,12 +50,14 @@ after_test: # 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct # interpreter - ps: if ($(& $env:PYTHON_EXE .\ci\get_version.py) -ne '') {& $env:PYTHON_EXE setup.py bdist_wheel} ELSE {echo "Not building because this is not a tag build"} - - ps: if ($LAST_EXIT_CODE -eq 'True') {ls dist} + - ps: if (& $env:PYTHON_EXE .\ci\get_version.py) {ls dist} + artifacts: # bdist_wheel puts your built wheel in the dist directory - path: dist\* -#on_success: +on_success: # You can use this step to upload your artifacts to a public website. # See Appveyor's documentation for more details. Or you can simply -# access your wheels from the Appveyor "artifacts" tab for your build. \ No newline at end of file +# access your wheels from the Appveyor "artifacts" tab for your build. + - ps if ($(& $env:PYTHON_EXE .\ci\get_version.py) -ne '') {& $env:PYTHON_EXE setup.py bdist_wheel} ELSE {echo "Not building because this is not a tag build"} \ No newline at end of file diff --git a/src/MTfit/algorithms/markov_chain_monte_carlo.py b/src/MTfit/algorithms/markov_chain_monte_carlo.py index 64be869..cc69773 100644 --- a/src/MTfit/algorithms/markov_chain_monte_carlo.py +++ b/src/MTfit/algorithms/markov_chain_monte_carlo.py @@ -1516,7 +1516,7 @@ def new_sample(self, jump=0.0, gaussian_jump=False): gaussian_jump=gaussian_jump) return mt except Exception: - logging.exception('Cython error') + logging.exception('WARNING: Error running cython code, resorting to python code') else: logger.info(C_EXTENSION_FALLBACK_LOG_MSG) # Otherwise/Fallback to use python code @@ -1611,7 +1611,8 @@ def _acceptance_check(self, xi_1, ln_pi_1, scale_factori_1=False): return xi_1, ln_pi_1, scale_factori_1[index], index return xi_1, ln_pi_1, False, index except Exception: - logger.exception('Cython Error') + if not isinstance(xi_1, dict): + logger.exception('WARNING: Error running cython code, resorting to python code') else: logger.info(C_EXTENSION_FALLBACK_LOG_MSG) # Otherwise use/fallback to Python code diff --git a/src/MTfit/probability/probability.py b/src/MTfit/probability/probability.py index 065512e..4e830b3 100644 --- a/src/MTfit/probability/probability.py +++ b/src/MTfit/probability/probability.py @@ -137,7 +137,7 @@ def polarity_ln_pdf(a, mt, sigma, incorrect_polarity_probability=0.0, _use_c=Non except Exception as e: # Run using python # Testing C code - logger.exception('Error running cython code') + logger.exception('WARNING: Error running cython code, resorting to python code') if _C_LIB_TESTS: raise e else: @@ -171,7 +171,7 @@ def polarity_ln_pdf(a, mt, sigma, incorrect_polarity_probability=0.0, _use_c=Non ln_p = cprobability.ln_prod(ln_p) except Exception: if cprobability: - logger.exception('Error running cython code') + logger.exception('WARNING: Error running cython code, resorting to python code') ln_p = np.sum(ln_p, 0) if isinstance(ln_p, np.ndarray): ln_p[np.isnan(ln_p)] = -np.inf @@ -255,7 +255,7 @@ def polarity_probability_ln_pdf(a, mt, positive_probability, negative_probabilit except Exception as e: # Run using python # Testing C code - logger.exception('Error running cython code') + logger.exception('WARNING: Error running cython code, resorting to python code') if _C_LIB_TESTS: raise e else: @@ -360,7 +360,7 @@ def amplitude_ratio_ln_pdf(ratio, mt, a_x, a_y, percentage_error_x, percentage_e except Exception as e: # Run using python # Testing C code - logger.exception('Error running cython code') + logger.exception('WARNING: Error running cython code, resorting to python code') if _C_LIB_TESTS: raise e else: @@ -394,7 +394,7 @@ def amplitude_ratio_ln_pdf(ratio, mt, a_x, a_y, percentage_error_x, percentage_e ln_p = cprobability.ln_prod(ln_p) except Exception: if cprobability: - logger.exception('Error running cython code') + logger.exception('WARNING: Error running cython code, resorting to python code') ln_p = np.sum(ln_p, 0) if isinstance(ln_p, np.ndarray): ln_p[np.isnan(ln_p)] = -np.inf @@ -479,7 +479,7 @@ def relative_amplitude_ratio_ln_pdf(x_1, x_2, mt_1, mt_2, a_1, a_2, percentage_e except Exception as e: # Run using python # Testing C code - logger.exception('Error running cython code') + logger.exception('WARNING: Error running cython code, resorting to python code') if _C_LIB_TESTS: raise e else: @@ -826,7 +826,7 @@ def dkl(ln_probability_p, ln_probability_q, dV=1.0): try: return cprobability.dkl(ln_probability_p.copy(), ln_probability_q.copy(), dV) except Exception: - logger.exception('Error running cython code') + logger.exception('WARNING: Error running cython code, resorting to python code') else: logger.info(C_EXTENSION_FALLBACK_LOG_MSG) ind = ln_probability_p > -np.inf @@ -845,7 +845,7 @@ def dkl(ln_probability_p, ln_probability_q, dV=1.0): ln_probability_q[ind]*probability_p[ind]) * dV -def ln_marginalise(ln_pdf, axis=0, dV=1.0): +def ln_marginalise(ln_pdf, axis=0, dV=1.0, _cprob_err=True): """ Marginalise the pdf from the log pdf input @@ -870,7 +870,8 @@ def ln_marginalise(ln_pdf, axis=0, dV=1.0): return cprobability.ln_marginalise(ln_pdf._ln_pdf.astype(np.float64)) return cprobability.ln_marginalise(ln_pdf.astype(np.float64)) except Exception: - logger.exception('Error running cython code') + if _cprob_err: + logger.exception('WARNING: Error running cython code, resorting to python code') else: logger.info(C_EXTENSION_FALLBACK_LOG_MSG) # scale and then marginalise: @@ -922,7 +923,7 @@ def ln_normalise(ln_pdf, dV=1): normalised_ln_pdf = cprobability.ln_normalise(ln_pdf) return normalised_ln_pdf except Exception: - logger.exception('Error running cython code') + logger.exception('WARNING: Error running cython code, resorting to python code') else: logger.info(C_EXTENSION_FALLBACK_LOG_MSG) # scale and then marginalise: @@ -993,7 +994,7 @@ def dkl_estimate(ln_pdf, V, N): try: return cprobability.dkl_uniform(ln_pdf.copy(), V, dV) except Exception: - logger.exception('Error running cython code') + logger.exception('WARNING: Error running cython code, resorting to python code') else: logger.info(C_EXTENSION_FALLBACK_LOG_MSG) ind = ln_pdf > -np.inf @@ -1263,17 +1264,18 @@ def output(self, normalise=True): return self.marginalise().normalise() return self.marginalise() - def exp(self): + def exp(self, _cprob_err=True): if cprobability: try: return cprobability.ln_exp(self._ln_pdf) except Exception: - logger.exception('Error running cython code') + if _cprob_err: + logger.exception('WARNING: Error running cython code, resorting to python code') else: logger.info(C_EXTENSION_FALLBACK_LOG_MSG) return np.exp(self._ln_pdf) - def nonzero(self, discard=100000., n_samples=0): + def nonzero(self, discard=100000., n_samples=0, _cprob_err=True): """ Return the non-zero indices of the pdf @@ -1286,7 +1288,7 @@ def nonzero(self, discard=100000., n_samples=0): discard: float - discard scale [default = 100000.] n_samples: integer - number of samples generated [default = 0] """ - ln_pdf = np.array(self.marginalise(axis=0)._ln_pdf).flatten() + ln_pdf = np.array(self.marginalise(axis=0, _cprob_err=_cprob_err)._ln_pdf).flatten() m_val = -np.inf if n_samples > 0 and discard > 0: m_val = max(ln_pdf) - np.log(discard*n_samples) @@ -1308,7 +1310,7 @@ def normalise(self, dV=False): new._ln_pdf = ln_normalise(self._ln_pdf, self.dV) return new - def marginalise(self, axis=0, dV=False): + def marginalise(self, axis=0, dV=False, _cprob_err=True): """ Marginalise the pdf object over a given axis @@ -1322,7 +1324,7 @@ def marginalise(self, axis=0, dV=False): if dV: self._set_dv(dV) new = self.__class__(dV=self.dV) - new._ln_pdf = ln_marginalise(self._ln_pdf, axis=axis, dV=self.dV) + new._ln_pdf = ln_marginalise(self._ln_pdf, axis=axis, dV=self.dV, _cprob_err=_cprob_err) return new def append(self, other, axis=1): diff --git a/src/MTfit/sampling.py b/src/MTfit/sampling.py index 95c1ddf..61536d6 100644 --- a/src/MTfit/sampling.py +++ b/src/MTfit/sampling.py @@ -170,7 +170,7 @@ def output(self, normalise=True, convert=False, n_samples=0, discard=10000, mcmc # Check if there are samples if len(ln_pdf): # Get non_zero samples - non_zero = ln_pdf.nonzero(discard=discard, n_samples=n_samples) + non_zero = ln_pdf.nonzero(discard=discard, n_samples=n_samples, _cprob_err=False) if discard and n_samples: output_string += 'After discard, '+str(non_zero.shape[0])+' samples remain\n\n' if len(ln_pdf.shape) > 1: @@ -428,7 +428,7 @@ def ln_bayesian_evidence(output, n_samples, prior=_6sphere_prior): p = prior(output['g'], output['d']) if not isinstance(output['ln_pdf'], LnPDF): output['ln_pdf'] = LnPDF(output['ln_pdf']) - return np.log((output['ln_pdf']+np.log(p)-output['ln_pdf']._ln_pdf.max()).exp().sum())+output['ln_pdf']._ln_pdf.max()-np.log(n_samples) + return np.log((output['ln_pdf']+np.log(p)-output['ln_pdf']._ln_pdf.max()).exp(_cprob_err=False).sum())+output['ln_pdf']._ln_pdf.max()-np.log(n_samples) def _convert(moment_tensors, i=None):