working on simpler integrating sequence
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from scgenerator.operators import CurrentState
|
||||
from scgenerator.operators import SimulationState
|
||||
|
||||
|
||||
def test_creation():
|
||||
x = (np.linspace(0, 1, 128, dtype=complex),)
|
||||
cs = CurrentState(1.0, 0, 0.1, x, 1.0)
|
||||
x = np.linspace(0, 1, 128, dtype=complex)
|
||||
cs = SimulationState(1.0, 0, 0.1, x, 1.0)
|
||||
|
||||
assert cs.converter is np.fft.ifft
|
||||
assert cs.stats == {}
|
||||
assert np.allclose(cs.spectrum2, np.abs(np.fft.ifft(x)) ** 2)
|
||||
assert np.allclose(cs.field2, np.abs(np.fft.ifft(x)) ** 2)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
cs = CurrentState(1.0, 0, 0.0, x, 1.0, spectrum2=np.abs(x) ** 3)
|
||||
cs = SimulationState(1.0, 0, 0.0, x, 1.0, spectrum2=np.abs(x) ** 3)
|
||||
|
||||
cs = CurrentState(1.0, 0, 0.1, x, 1.0, spectrum2=x.copy(), field=x.copy(), field2=x.copy())
|
||||
cs = SimulationState(1.0, 0, 0.1, x, 1.0, spectrum2=x.copy(), field=x.copy(), field2=x.copy())
|
||||
|
||||
assert np.allclose(cs.spectrum2, cs.spectrum)
|
||||
assert np.allclose(cs.spectrum, cs.field)
|
||||
@@ -23,9 +23,9 @@ def test_creation():
|
||||
|
||||
|
||||
def test_copy():
|
||||
x = (np.linspace(0, 1, 128, dtype=complex),)
|
||||
cs = CurrentState(1.0, 0, 0.1, x, 1.0)
|
||||
cs2 = cs.copy()
|
||||
x = np.linspace(0, 1, 128, dtype=complex)
|
||||
start = SimulationState(1.0, 0, 0.1, x, 1.0)
|
||||
end = start.copy()
|
||||
|
||||
assert cs.spectrum is not cs2.spectrum
|
||||
assert np.all(cs.field2 == cs2.field2)
|
||||
assert start.spectrum is not end.spectrum
|
||||
assert np.all(start.field2 == end.field2)
|
||||
|
||||
Reference in New Issue
Block a user