Skip to content

Commit

Permalink
⬆️ Bump numpy from 1.26.4 to 2.0.1 (#1523)
Browse files Browse the repository at this point in the history
* Bump numpy from 1.26.4 to 2.1.0

Bumps [numpy](https://github.com/numpy/numpy) from 1.26.4 to 2.1.0.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst)
- [Commits](numpy/numpy@v1.26.4...v2.1.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* 🩹 Fix repr issue with numpy>2 str values

This caused the following test error:
```py
FAILED glotaran/utils/test/test_io.py::test_create_clp_guide_dataset_errors - assert "Unknown clp_...'species_3')]" == "Unknown clp_... 'species_3']"

  Skipping 49 identical leading characters in diff, use -v to show
    ls are:
  -  ['species_1', 'species_2', 'species_3']
  +  [np.str_('species_1'), np.str_('species_2'), np.str_('species_3')]
```

* ⬆️ Correct minor version of numpy

numpy 2.1 is not yet supported be e.g. numba

* Use .to_numpy instead of .values

* 🩹 Use add_svd_to_dataset instead of duplication with error

This way we can reuse code and fixes and don't have the extra duplication and maintenance burden

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: s-weigand <s.weigand.phy@gmail.com>
Co-authored-by: Joris Snellenburg <jsnel@users.noreply.github.com>
  • Loading branch information
4 people authored Aug 25, 2024
1 parent 2ef4cea commit a5fdc38
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
14 changes: 2 additions & 12 deletions glotaran/optimization/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
import xarray as xr

from glotaran.io.prepare_dataset import add_svd_to_dataset
from glotaran.model.data_model import iterate_data_model_elements
from glotaran.model.data_model import iterate_data_model_global_elements
from glotaran.optimization.data import LinkedOptimizationData
Expand Down Expand Up @@ -256,18 +257,7 @@ def finalize_result_dataset(self, dataset: xr.Dataset, data: OptimizationData, a

if add_svd:
for name in ["data", "residual"]:
if f"{name}_singular_values" in dataset:
continue
lsv, sv, rsv = np.linalg.svd(dataset[name], full_matrices=False)
dataset[f"{name}_left_singular_vectors"] = (
(data.model_dimension, "left_singular_value_index"),
lsv,
)
dataset[f"{name}_singular_values"] = (("singular_value_index"), sv)
dataset[f"{name}_right_singular_vectors"] = (
(data.global_dimension, "right_singular_value_index"),
rsv.T,
)
add_svd_to_dataset(dataset, name, data.model_dimension, data.global_dimension)
for _, model in iterate_data_model_elements(data.model):
model.add_to_result_data( # type:ignore[union-attr]
data.model, dataset, False
Expand Down
2 changes: 1 addition & 1 deletion glotaran/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def create_clp_guide_dataset(
if clp_label not in dataset.clp_label:
raise ValueError(
f"Unknown clp_label {clp_label!r}. "
f"Known clp_labels are:\n {list(dataset.clp_label.values)}"
f"Known clp_labels are:\n {[str(label) for label in dataset.clp_label.to_numpy()]}"
)
if "model_dimension" not in dataset.attrs:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies = [
"asteval!=0.9.28,>=0.9.22",
"netCDF4>=1.5.7",
"numba>=0.55",
"numpy<1.27,>=1.21.2",
"numpy<2.1,>=1.21.2",
"odfpy>=1.4.1",
"openpyxl>=3.0.10",
"pandas>=1.3.4",
Expand Down
2 changes: 1 addition & 1 deletion requirements_pinned.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
asteval==1.0.2
netCDF4==1.7.1.post1
numba==0.60.0
numpy==1.26.4
numpy==2.0.1
odfpy==1.4.1
openpyxl==3.1.5
pandas==2.2.2
Expand Down

0 comments on commit a5fdc38

Please sign in to comment.