Skip to content

Commit

Permalink
Merge pull request #88 from hanjinliu/fix-random-seed
Browse files Browse the repository at this point in the history
Fix random seed problem
  • Loading branch information
hanjinliu authored Jun 30, 2024
2 parents 22f5d1b + 858602f commit b43d5c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
12 changes: 8 additions & 4 deletions cylindra/project/_layer_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from acryo import Molecules
from napari.layers import Layer
from pydantic import BaseModel

Expand Down Expand Up @@ -75,11 +76,9 @@ def from_layer(
point_size=layer.point_size,
)

def to_layer(self, gui: "CylindraMainWidget", project_dir: Path):
def to_molecules(self, project_dir: Path) -> "Molecules":
from acryo import Molecules

from cylindra._napari import MoleculesLayer

path = project_dir / self.name
if not path.exists():
warnings.warn(
Expand All @@ -88,7 +87,12 @@ def to_layer(self, gui: "CylindraMainWidget", project_dir: Path):
stacklevel=2,
)
return
mole = Molecules.from_file(path)
return Molecules.from_file(path)

def to_layer(self, gui: "CylindraMainWidget", project_dir: Path):
from cylindra._napari import MoleculesLayer

mole = self.to_molecules(project_dir)

if self.source is not None:
src = gui.tomogram.splines[self.source]
Expand Down
14 changes: 7 additions & 7 deletions src/annealing/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,14 @@ impl CylindricAnnealingModel {
reject_count = 0;
} else {
reject_count += 1;
}
if reject_count > self.reject_limit {
if self.graph.energy() == std::f32::INFINITY {
self.optimization_state = OptimizationState::Failed;
} else {
self.optimization_state = OptimizationState::Converged;
if reject_count > self.reject_limit {
if self.graph.energy() == std::f32::INFINITY {
self.optimization_state = OptimizationState::Failed;
} else {
self.optimization_state = OptimizationState::Converged;
}
break;
}
break;
}
self.iteration += 1;
self.reservoir.cool(self.iteration);
Expand Down
2 changes: 1 addition & 1 deletion src/annealing/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Clone for RandomNumberGenerator {
}
}

const BUF: usize = 1;
const BUF: usize = 2;
const SCALE: f32 = (1 << (24 - BUF)) as f32;

impl RandomNumberGenerator {
Expand Down

0 comments on commit b43d5c9

Please sign in to comment.