From f14b597e2d34200d419994be5dfea51c956ab892 Mon Sep 17 00:00:00 2001 From: krzywon Date: Tue, 10 Sep 2024 16:50:24 -0400 Subject: [PATCH 1/9] Iterating through bumps MultiFitProblem.models now returns the Fitness object. Update to match the new functionality --- src/sas/sascalc/fit/BumpsFitting.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sas/sascalc/fit/BumpsFitting.py b/src/sas/sascalc/fit/BumpsFitting.py index 77f6b2f63d..985cff3f15 100644 --- a/src/sas/sascalc/fit/BumpsFitting.py +++ b/src/sas/sascalc/fit/BumpsFitting.py @@ -316,8 +316,7 @@ def fit(self, msg_q=None, # Check if uncertainty is missing for any parameter uncertainty_warning = False - for fitting_module in problem.models: - fitness = fitting_module.fitness + for fitness in problem.models: pars = fitness.fitted_pars + fitness.computed_pars par_names = fitness.fitted_par_names + fitness.computed_par_names From 824d7824ebb171b50be37cd010f96009d3b1e3f9 Mon Sep 17 00:00:00 2001 From: krzywon Date: Wed, 11 Sep 2024 10:35:35 -0400 Subject: [PATCH 2/9] Remove all calls to setup.py to help future-proof the build process --- .github/workflows/ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b55a1ae6b..e90d8f9fc8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,8 +119,6 @@ jobs: cd ../sasdata rm -rf build rm -rf dist - python setup.py clean - python setup.py build mv build/lib/sasdata/example_data/* ../sasview/src/sas/example_data/ python -m pip install --no-deps . @@ -129,8 +127,6 @@ jobs: cd ../sasmodels rm -rf build rm -rf dist - python setup.py clean - python setup.py build python -m pip install --no-deps . - name: Build and install bumps @@ -138,8 +134,6 @@ jobs: cd ../bumps rm -rf build rm -rf dist - python setup.py clean - python setup.py build python -m pip install --no-deps . ### Document the build environment @@ -156,8 +150,6 @@ jobs: githash=$( git rev-parse HEAD ) sed -i.bak s/GIT_COMMIT/$githash/g src/sas/sasview/__init__.py # BUILD SASVIEW - python setup.py clean - python setup.py build python -m pip install --no-deps . ### Run tests (if enabled) From f95ee9a47cde41053921835286ecc238693590df Mon Sep 17 00:00:00 2001 From: krzywon Date: Wed, 11 Sep 2024 10:46:33 -0400 Subject: [PATCH 3/9] Move example data from base sasdata package instead of built package --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e90d8f9fc8..b961885ede 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,7 +119,7 @@ jobs: cd ../sasdata rm -rf build rm -rf dist - mv build/lib/sasdata/example_data/* ../sasview/src/sas/example_data/ + mv sasdata/example_data/* ../sasview/src/sas/example_data/ python -m pip install --no-deps . - name: Build and install sasmodels From 6c6448f98bc7bf763838e8167957808262934cf2 Mon Sep 17 00:00:00 2001 From: krzywon Date: Mon, 28 Oct 2024 15:28:12 -0400 Subject: [PATCH 4/9] Update requirements.txt to allow latest versions of numpy, scipy, and PySide, while keeping bumps less than 1.0 --- build_tools/requirements.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build_tools/requirements.txt b/build_tools/requirements.txt index 5bff233141..fab5feb3a4 100644 --- a/build_tools/requirements.txt +++ b/build_tools/requirements.txt @@ -1,6 +1,5 @@ # Alphabetized list of OS and version agnostic dependencies appdirs -bumps cffi docutils dominate @@ -14,16 +13,19 @@ lxml mako matplotlib numba +numpy periodictable pybind11 pylint pyopengl pyparsing +PySide6 pytest pytest_qt pytest-mock pytools qtconsole +scipy six sphinx superqt @@ -38,6 +40,4 @@ zope pywin32; platform_system == "Windows" # Alphabetized list of version-pinned packages -numpy==1.26.4 # 2.0.0 deprecates many functions used in the codebase (and potentially in dependencies) -PySide6==6.4.3 # Later versions do not mesh well with pyinstaller < 6.0 -scipy==1.13.1 # 1.14 deprecates some functions used in the codebase (and potentially in dependencies) +bumps==0.* # v1.+ is very experimental From 56a02256672c9451389e074cee08605886375fc8 Mon Sep 17 00:00:00 2001 From: krzywon Date: Mon, 28 Oct 2024 15:28:34 -0400 Subject: [PATCH 5/9] numpy.NaN -> numpy.nan --- src/sas/sascalc/fit/BumpsFitting.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sas/sascalc/fit/BumpsFitting.py b/src/sas/sascalc/fit/BumpsFitting.py index 985cff3f15..7fbc96067a 100644 --- a/src/sas/sascalc/fit/BumpsFitting.py +++ b/src/sas/sascalc/fit/BumpsFitting.py @@ -346,8 +346,8 @@ def fit(self, msg_q=None, # TODO: Let the GUI decided how to handle success/failure. if not fitting_result.success: - fitting_result.stderr[:] = np.NaN - fitting_result.fitness = np.NaN + fitting_result.stderr[:] = np.nan + fitting_result.fitness = np.nan all_results.append(fitting_result) @@ -398,7 +398,7 @@ def abort_test(): try: best, fbest = fitdriver.fit() except Exception as exc: - best, fbest = None, np.NaN + best, fbest = None, np.nan errors.extend([str(exc), traceback.format_exc()]) finally: mapper.stop_mapper(fitdriver.mapper) From fd26edb0abdb8c2383c6f48ed32a5dc3fe9d05ee Mon Sep 17 00:00:00 2001 From: krzywon Date: Mon, 28 Oct 2024 15:36:34 -0400 Subject: [PATCH 6/9] Apply compatibility patch to BumpsFitting.py to allow for bumps v0 and v1 --- src/sas/sascalc/fit/BumpsFitting.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sas/sascalc/fit/BumpsFitting.py b/src/sas/sascalc/fit/BumpsFitting.py index 7fbc96067a..c933290514 100644 --- a/src/sas/sascalc/fit/BumpsFitting.py +++ b/src/sas/sascalc/fit/BumpsFitting.py @@ -316,7 +316,14 @@ def fit(self, msg_q=None, # Check if uncertainty is missing for any parameter uncertainty_warning = False - for fitness in problem.models: + for fitting_module in problem.models: + # This makes BumpsFitting compatible with both bumps v0.9 and v1.0 + if isinstance(fitting_module, SasFitness): + # Bumps v1+ - A Fitness object is returned + fitness = fitting_module + else: + # Bumps v0 - A module is returned that holds the Fitness object + fitness = fitting_module.fitness pars = fitness.fitted_pars + fitness.computed_pars par_names = fitness.fitted_par_names + fitness.computed_par_names From 0ca1b82a5bd78f599df208d5bbe282a8cbf7aac3 Mon Sep 17 00:00:00 2001 From: krzywon Date: Mon, 28 Oct 2024 15:59:41 -0400 Subject: [PATCH 7/9] Include periodictable in parallel repos until next version is released --- .github/workflows/ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b961885ede..f092613528 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,7 +112,8 @@ jobs: run: | git clone --depth=50 --branch=master https://github.com/SasView/sasdata.git ../sasdata git clone --depth=50 --branch=master https://github.com/SasView/sasmodels.git ../sasmodels - git clone --depth=50 --branch=master https://github.com/bumps/bumps.git ../bumps + git clone --depth=50 --branch=v0.9.3 https://github.com/bumps/bumps.git ../bumps + git clone --depth=50 --branch=master https://github.com/pkienzle/periodictable.git ../periodictable - name: Build and install sasdata run: | @@ -136,6 +137,13 @@ jobs: rm -rf dist python -m pip install --no-deps . + - name: Build and install periodictable + run: | + cd ../periodictable + rm -rf build + rm -rf dist + python -m pip install --no-deps . + ### Document the build environment - name: Python package version list From e17d2d6c4518c26cd1cfd3b7e4f13097faa7b0be Mon Sep 17 00:00:00 2001 From: krzywon Date: Mon, 28 Oct 2024 16:30:59 -0400 Subject: [PATCH 8/9] Go back to using pip installed version of periodictable --- .github/workflows/ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f092613528..838926f5f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,7 +113,6 @@ jobs: git clone --depth=50 --branch=master https://github.com/SasView/sasdata.git ../sasdata git clone --depth=50 --branch=master https://github.com/SasView/sasmodels.git ../sasmodels git clone --depth=50 --branch=v0.9.3 https://github.com/bumps/bumps.git ../bumps - git clone --depth=50 --branch=master https://github.com/pkienzle/periodictable.git ../periodictable - name: Build and install sasdata run: | @@ -137,13 +136,6 @@ jobs: rm -rf dist python -m pip install --no-deps . - - name: Build and install periodictable - run: | - cd ../periodictable - rm -rf build - rm -rf dist - python -m pip install --no-deps . - ### Document the build environment - name: Python package version list From 2b3969ba3735db825eef28b42e3aa17efd5cd813 Mon Sep 17 00:00:00 2001 From: krzywon Date: Tue, 3 Dec 2024 11:15:12 -0500 Subject: [PATCH 9/9] Update documentation related to bumps returns to ensure consistent behavior moving forward --- src/sas/sascalc/fit/BumpsFitting.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sas/sascalc/fit/BumpsFitting.py b/src/sas/sascalc/fit/BumpsFitting.py index c933290514..9d75816f8b 100644 --- a/src/sas/sascalc/fit/BumpsFitting.py +++ b/src/sas/sascalc/fit/BumpsFitting.py @@ -317,12 +317,12 @@ def fit(self, msg_q=None, uncertainty_warning = False for fitting_module in problem.models: - # This makes BumpsFitting compatible with both bumps v0.9 and v1.0 + # CRUFT: This makes BumpsFitting compatible with bumps v0.9 and v1.0 if isinstance(fitting_module, SasFitness): - # Bumps v1+ - A Fitness object is returned + # Bumps v1.x+ - A Fitness object is returned fitness = fitting_module else: - # Bumps v0 - A module is returned that holds the Fitness object + # Bumps v0.x - A module is returned that holds the Fitness object fitness = fitting_module.fitness pars = fitness.fitted_pars + fitness.computed_pars par_names = fitness.fitted_par_names + fitness.computed_par_names