Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit afdaa5c

Browse files
committed
make sure different classes have different results
1 parent 68eb528 commit afdaa5c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

python/pyspark/ml/tests.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ def __init__(self, seed=None):
122122
self._setDefault(maxIter=10)
123123
self._set(seed=seed)
124124

125+
class OtherTestParams(HasMaxIter, HasInputCol, HasSeed):
126+
"""
127+
A subclass of Params mixed with HasMaxIter, HasInputCol and HasSeed.
128+
"""
129+
130+
def __init__(self, seed=None):
131+
super(OtherTestParams, self).__init__()
132+
self._setDefault(maxIter=10)
133+
self._set(seed=seed)
134+
125135

126136
class ParamTests(PySparkTestCase):
127137

@@ -168,14 +178,16 @@ def test_params(self):
168178
def test_hasseed(self):
169179
noSeedSpecd = TestParams()
170180
withSeedSpecd = TestParams(seed=42)
181+
other = OtherTestParams()
171182
# Check that we no longer use 42 as the magic number
172183
self.assertNotEqual(noSeedSpecd.getSeed(), 42)
173184
origSeed = noSeedSpecd.getSeed()
174185
# Check that we only compute the seed once
175186
self.assertEqual(noSeedSpecd.getSeed(), origSeed)
176187
# Check that a specified seed is honored
177188
self.assertEqual(withSeedSpecd.getSeed(), 42)
178-
189+
# Check that a different class has a different seed
190+
self.assertNotEqual(other.getSeed(), oSeedSpeced.getSeed())
179191

180192
if __name__ == "__main__":
181193
unittest.main()

0 commit comments

Comments
 (0)