1
+ # to ensure that propertynames that aren't fieldnames are always viewed as
2
+ # "defined", in MLJType objects. See #115.
3
+ function _isdefined (object, name)
4
+ pnames = propertynames (object)
5
+ fnames = fieldnames (typeof (object))
6
+ name in pnames && ! (name in fnames) && return true
7
+ isdefined (object, name)
8
+ end
9
+
1
10
function _equal_to_depth_one (x1, x2)
2
11
names = propertynames (x1)
3
12
names === propertynames (x2) || return false
@@ -68,7 +77,8 @@ following conditions all hold, and `false` otherwise:
68
77
69
78
- with the exception of properties listed as `exceptions` or bound to
70
79
an `AbstractRNG`, each pair of corresponding property values is
71
- either "equal" or both undefined.
80
+ either "equal" or both undefined. (If a property appears as a
81
+ `propertyname` but not a `fieldname`, it is deemed as always defined.)
72
82
73
83
The meaining of "equal" depends on the type of the property value:
74
84
@@ -93,9 +103,9 @@ function is_same_except(m1::M1,
93
103
94
104
for name in names
95
105
if ! (name in exceptions)
96
- if ! isdefined (m1, name)
97
- ! isdefined (m2, name) || return false
98
- elseif isdefined (m2, name)
106
+ if ! _isdefined (m1, name)
107
+ ! _isdefined (m2, name) || return false
108
+ elseif _isdefined (m2, name)
99
109
if name in deep_properties (M1)
100
110
_equal_to_depth_one (getproperty (m1,name),
101
111
getproperty (m2, name)) || return false
0 commit comments