Skip to content

Commit 34a581d

Browse files
Relax === to == in projection_isequal
Which fixes a bug that can occur when serializing models.
1 parent b2a9566 commit 34a581d

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.3.9] - 2024-03-04
11+
12+
### Fixed
13+
14+
* Relax `===` to `==` when comparing some models. (This fixes a bug when a model is saved to disk using e.g. JLD2 and the loaded again.)
15+
1016
## [0.3.8] - 2024-02-22
1117

1218
### Added

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SingleCellProjections"
22
uuid = "03d38035-ed2f-4a36-82eb-797f1727ab2e"
33
authors = ["Rasmus Henningsson <rasmus.henningsson@med.lu.se>"]
4-
version = "0.3.8"
4+
version = "0.3.9"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

ext/SingleCellProjectionsPrincipalMomentAnalysisExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct PMAModel <: ProjectionModel
6666
obs::Symbol
6767
end
6868
69-
SingleCellProjections.projection_isequal(m1::PMAModel, m2::PMAModel) = m1.F === m2.F && m1.var_match == m2.var_match
69+
SingleCellProjections.projection_isequal(m1::PMAModel, m2::PMAModel) = m1.F == m2.F && m1.var_match == m2.var_match
7070
SingleCellProjections.update_model(m::PMAModel; var=m.var, obs=m.obs, kwargs...) = (SVDModel(m.F, m.var_match, var, obs), kwargs)
7171
7272
"""

ext/SingleCellProjectionsUMAPExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct UMAPModel <: ProjectionModel
1010
obs::Symbol
1111
end
1212

13-
SingleCellProjections.projection_isequal(m1::UMAPModel, m2::UMAPModel) = m1.m === m2.m && m1.var_match == m2.var_match
13+
SingleCellProjections.projection_isequal(m1::UMAPModel, m2::UMAPModel) = m1.m == m2.m && m1.var_match == m2.var_match
1414

1515
SingleCellProjections.update_model(m::UMAPModel; obs=m.obs, kwargs...) = (UMAPModel(m.m, m.var_match, obs), kwargs)
1616

src/normalize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct NormalizationModel <: ProjectionModel
4343
end
4444
4545
function projection_isequal(m1::NormalizationModel, m2::NormalizationModel)
46-
m1.negβT === m2.negβT && m1.covariates == m2.covariates && m1.rank == m2.rank &&
46+
m1.negβT == m2.negβT && m1.covariates == m2.covariates && m1.rank == m2.rank &&
4747
m1.var_match == m2.var_match && m1.scaling == m2.scaling
4848
end
4949

src/reduce.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end
1515

1616
# NB: Require Factorizations to be ===. This is faster and more reasonable.
1717
# Because of numerical issues, we should never expect Factorizations to be equal if they are not identical.
18-
projection_isequal(m1::SVDModel, m2::SVDModel) = m1.F === m2.F && m1.var_match == m2.var_match
18+
projection_isequal(m1::SVDModel, m2::SVDModel) = m1.F == m2.F && m1.var_match == m2.var_match
1919

2020

2121
update_model(m::SVDModel; var=m.var, obs=m.obs, kwargs...) = (SVDModel(m.F, m.var_match, var, obs), kwargs)
@@ -70,8 +70,7 @@ NearestNeighborModel(name, pre::DataMatrix, post::DataMatrix; kwargs...) =
7070
NearestNeighborModel(name, pre, obs_coordinates(post); kwargs...)
7171
7272
function projection_isequal(m1::NearestNeighborModel, m2::NearestNeighborModel)
73-
# NB: === for factorizations/matrices
74-
m1.name == m2.name && m1.pre === m2.pre && m1.post === m2.post &&
73+
m1.name == m2.name && m1.pre == m2.pre && m1.post == m2.post &&
7574
m1.var_match == m2.var_match && m1.k == m2.k
7675
end
7776

0 commit comments

Comments
 (0)