Skip to content

Commit

Permalink
Substitution for np random rng
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSalinas98 authored Mar 14, 2024
1 parent d7066da commit fe895af
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions xmipptomo/protocols/protocol_phantom_subtomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,6 @@ def applyRandomOrientation(self, fnIn, fnOut):
shiftX = rng.integers(self.xmin.get(), self.xmax.get())
shiftY = rng.integers(self.ymin.get(), self.ymax.get())
shiftZ = rng.integers(self.zmin.get(), self.zmax.get())
#shiftX = np.random.randint(self.xmin.get(), self.xmax.get())
#shiftY = np.random.randint(self.ymin.get(), self.ymax.get())
#shiftZ = np.random.randint(self.zmin.get(), self.zmax.get())


self.runJob("xmipp_transform_geometry",
Expand Down Expand Up @@ -418,9 +415,10 @@ def _addCoordinate(self, subtomo, tomo):
coor = Coordinate3D()
coor.setVolume(tomo)
tomoDim = tomo.getDim()
coor.setX(np.random.randint(0, tomoDim[0]), const.BOTTOM_LEFT_CORNER)
coor.setY(np.random.randint(0, tomoDim[1]), const.BOTTOM_LEFT_CORNER)
coor.setZ(np.random.randint(0, tomoDim[2]), const.BOTTOM_LEFT_CORNER)
rng = np.random.default_rng()

Check notice

Code scanning / SonarCloud

Results that depend on random number generation should be reproducible Low

Provide a seed for this random generator. See more on SonarCloud
coor.setX(rng.integers(tomoDim[0]), const.BOTTOM_LEFT_CORNER)
coor.setY(rng.integers(tomoDim[1]), const.BOTTOM_LEFT_CORNER)
coor.setZ(rng.integers(tomoDim[2]), const.BOTTOM_LEFT_CORNER)

self.coordsSet.append(coor)
self.coordsSet.setBoxSize(subtomo.getDim()[0])
Expand Down

0 comments on commit fe895af

Please sign in to comment.