Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitffd9fd2

Browse files
fix more data races in mtrand.pyx (#30426)
1 parent5878318 commitffd9fd2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

‎numpy/random/mtrand.pyx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,13 @@ cdef class RandomState:
222222
"be instantized.")
223223
self._bitgen= (<bitgen_t*>PyCapsule_GetPointer(capsule,name))[0]
224224
self._aug_state.bit_generator=&self._bitgen
225-
self._reset_gauss()
226225
self.lock=bit_generator.lock
226+
self._reset_gauss()
227227

228228
cdef_reset_gauss(self):
229-
self._aug_state.has_gauss=0
230-
self._aug_state.gauss=0.0
229+
withself.lock:
230+
self._aug_state.has_gauss=0
231+
self._aug_state.gauss=0.0
231232

232233
defseed(self,seed=None):
233234
"""
@@ -301,8 +302,9 @@ cdef class RandomState:
301302
'MT19937 BitGenerator. To silence this warning, '
302303
'set `legacy` to False.',RuntimeWarning)
303304
legacy=False
304-
st['has_gauss']=self._aug_state.has_gauss
305-
st['gauss']=self._aug_state.gauss
305+
withself.lock:
306+
st['has_gauss']=self._aug_state.has_gauss
307+
st['gauss']=self._aug_state.gauss
306308
iflegacyandnotisinstance(self._bit_generator,_MT19937):
307309
raiseValueError(
308310
"legacy can only be True when the underlying bitgenerator is "

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp