From 9f9a17aeb1d50ad9cafd7dd599823bb18eb9116e Mon Sep 17 00:00:00 2001 From: Antoine Cornillot <61453516+a-corni@users.noreply.github.com> Date: Wed, 8 Nov 2023 16:58:15 +0100 Subject: [PATCH] Fix temperature initialization in SimConfig (#606) --- pulser-simulation/pulser_simulation/simconfig.py | 2 +- tests/test_simconfig.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pulser-simulation/pulser_simulation/simconfig.py b/pulser-simulation/pulser_simulation/simconfig.py index 54f469aa..430df3dd 100644 --- a/pulser-simulation/pulser_simulation/simconfig.py +++ b/pulser-simulation/pulser_simulation/simconfig.py @@ -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() diff --git a/tests/test_simconfig.py b/tests/test_simconfig.py index 6662ceab..9703883d 100644 --- a/tests/test_simconfig.py +++ b/tests/test_simconfig.py @@ -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 ( @@ -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(