Skip to content

Commit d6e95a7

Browse files
ablaomtlienart
authored andcommitted
Patch release 0.7.3 (#75)
* resolve problem with == #74 * bump to 0.7.3
1 parent aed7b79 commit d6e95a7

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MLJBase"
22
uuid = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
33
authors = ["Anthony D. Blaom <[email protected]>"]
4-
version = "0.7.2"
4+
version = "0.7.3"
55

66
[deps]
77
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"

src/MLJBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Users of this module should first read the document
22
# https://alan-turing-institute.github.io/MLJ.jl/dev/adding_models_for_general_use/
3-
module MLJBase
3+
module MLJBase
44

55
export MLJType, Model, Supervised, Unsupervised
66
export Deterministic, Probabilistic, Interval

src/equality.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Note that Base.== is overloaded such that `m1 == m2` if and only if
1414
`is_same_except(m1, m2)`.
1515
1616
"""
17+
is_same_except(x1, x2) = ==(x1, x2)
1718
function is_same_except(m1::M1, m2::M2,
1819
exceptions::Symbol...) where {M1<:MLJType,M2<:MLJType}
1920
if typeof(m1) != typeof(m2)
@@ -31,9 +32,9 @@ function is_same_except(m1::M1, m2::M2,
3132
same_values = true
3233
for fld in defined1
3334
same_values = same_values &&
34-
(getfield(m1, fld) == getfield(m2, fld) ||
35-
getfield(m1, fld) isa AbstractRNG) ||
36-
getfield(m2, fld) isa AbstractRNG
35+
(is_same_except(getfield(m1, fld), getfield(m2, fld)) ||
36+
getfield(m1, fld) isa AbstractRNG ||
37+
getfield(m2, fld) isa AbstractRNG)
3738
end
3839
return same_values
3940
end

test/equality.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,20 @@ f1.y = 20
2828
@test f1 != f2
2929
@test is_same_except(f1, f2, :x, :y)
3030

31+
# test for nested fields
32+
33+
mutable struct Super <: MLJType
34+
sub::Foo
35+
z::Int
36+
end
37+
38+
f1 = Foo(MersenneTwister(7), 1, 2)
39+
f2 = Foo(MersenneTwister(8), 1, 2)
40+
s1 = Super(f1, 20)
41+
s2 = Super(f2, 20)
42+
@test s1 == s2
43+
s2.sub.x = 10
44+
@test f1 != f2
45+
46+
3147
true

0 commit comments

Comments
 (0)