Skip to content

Commit

Permalink
Fix temperature initialization in SimConfig (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-corni authored Nov 8, 2023
1 parent 2bad427 commit 9f9a17a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pulser-simulation/pulser_simulation/simconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def __post_init__(self) -> None:
raise TypeError(
f"'temperature' must be a float, not {type(self.temperature)}."
)
self._change_attribute("temperature", self.temperature * 1e-6)
self._change_attribute("temperature", self.temperature / 1e6)

# Kept to show error messages with the right parameter names
self._check_spam_dict()
Expand Down
3 changes: 3 additions & 0 deletions tests/test_simconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_init():
temperature=1000.0,
runs=100,
)
assert config.temperature == 1e-3 # in K
str_config = config.__str__(True)
assert "SPAM, doppler, dephasing, amplitude" in str_config
assert (
Expand All @@ -49,6 +50,8 @@ def test_init():
and "Solver Options" in str_config
)
config = SimConfig(noise="depolarizing")
assert config.temperature == 5e-5
assert config.to_noise_model().temperature == 50
str_config = config.__str__(True)
assert "depolarizing" in str_config
config = SimConfig(
Expand Down

0 comments on commit 9f9a17a

Please sign in to comment.