Skip to content

Commit

Permalink
Maintenance/patches for v0.3.3 (#599)
Browse files Browse the repository at this point in the history
* Force recalculation of SVD attributes in scheme._prepare_data Fixes #597
* 🔨 Remove no-op code related to new_dims 
* Remove unneeded check in spectral_penalties._get_area Fixes #598
* Add python 3.9 support (#450)
* Bump numba dependencies as needed for Python 3.9
  • Loading branch information
jsnel authored Mar 18, 2021
1 parent 22f05f5 commit 67dacce
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI_CD_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install -U pip wheel
pip install .
python -m pip install -U -r requirements_dev.txt
pip install .
- name: Show installed packages
run: pip freeze
- name: Build docs
Expand All @@ -43,8 +43,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install -U pip wheel
pip install .
python -m pip install -U -r requirements_dev.txt
pip install .
- name: Show installed packages
run: pip freeze
- name: Check doc links
Expand All @@ -61,7 +61,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: [3.8]
python-version: [3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a `docstring`_.
3. The pull request should work for Python 3.8
3. The pull request should work for Python 3.8 and 3.9
Check your Github Actions ``https://github.com/<your_name_here>/pyglotaran/actions``
and make sure that the tests pass for all supported Python versions.

Expand Down
31 changes: 8 additions & 23 deletions glotaran/analysis/scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,29 +202,14 @@ def _prepare_data(self, data: dict[str, xr.DataArray | xr.Dataset]):
dataset = self._transpose_dataset(dataset)
self._add_weight(label, dataset)

# This protects transposing when getting data with svd in it
if "data_singular_values" in dataset and (
dataset.coords["right_singular_value_index"].size
!= dataset.coords[self.model.global_dimension].size
):
dataset = dataset.rename(
right_singular_value_index="right_singular_value_indexTMP"
)
dataset = dataset.rename(left_singular_value_index="right_singular_value_index")
dataset = dataset.rename(right_singular_value_indexTMP="left_singular_value_index")
dataset = dataset.rename(right_singular_vectors="right_singular_value_vectorsTMP")
dataset = dataset.rename(
left_singular_value_vectors="right_singular_value_vectors"
)
dataset = dataset.rename(
right_singular_value_vectorsTMP="left_singular_value_vectors"
)
new_dims = [self.model.model_dimension, self.model.global_dimension]
new_dims += [
dim
for dim in dataset.dims
if dim not in [self.model.model_dimension, self.model.global_dimension]
]
# TODO: avoid computation if not requested
l, s, r = np.linalg.svd(dataset.data, full_matrices=False)
dataset["data_left_singular_vectors"] = (("time", "left_singular_value_index"), l)
dataset["data_singular_values"] = (("singular_value_index"), s)
dataset["data_right_singular_vectors"] = (
("right_singular_value_index", "spectral"),
r,
)

self._data[label] = dataset

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ def _get_area(
start_idx, end_idx = _get_idx_from_interval(interval, global_axis)
for i in range(start_idx, end_idx + 1):
index_clp_labels = clp_labels[label][i] if index_dependent else clp_labels[label]
if area and np.any(np.isclose(area_indices, global_axis[i], atol=group_tolerance)):
# already got clp for this index
continue
if compartment in index_clp_labels:
area.append(clps[label][i][index_clp_labels.index(compartment)])
area_indices.append(global_axis[i])
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ asteval==0.9.22
numpy==1.20.1
scipy==1.6.1
click==7.1.2
numba==0.52.0
numba==0.53.0
pandas==1.2.2
pyyaml==5.4.1
xarray==0.16.2
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ classifiers =
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Scientific/Engineering
Topic :: Scientific/Engineering :: Chemistry
Topic :: Scientific/Engineering :: Physics
Expand All @@ -40,7 +41,7 @@ install_requires =
sdtfile>=2020.8.3
setuptools>=41.2
xarray>=0.16.2
python_requires = >=3.8, <3.9
python_requires = >=3.8, <3.10
setup_requires =
setuptools>=41.2
tests_require = pytest
Expand Down

0 comments on commit 67dacce

Please sign in to comment.