-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from h2020charisma/bugfix_and_tests
Bugfix and tests
- Loading branch information
Showing
3 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
import ramanchada2 as rc2 | ||
|
||
|
||
def test_spectrum_init(): | ||
with pytest.raises(ValueError): | ||
spe = rc2.spectrum.Spectrum(x=np.arange(100), y=np.arange(101)) | ||
with pytest.raises(ValueError): | ||
spe = rc2.spectrum.Spectrum(x=np.arange(100), y=np.arange(99)) | ||
spe = rc2.spectrum.Spectrum(x=np.arange(100, dtype=int), y=np.random.uniform(size=100)) | ||
assert spe.x.dtype == float | ||
assert spe.y.dtype == float | ||
spec = spe.__copy__() | ||
assert np.all(spe.x == spec.x) | ||
assert np.all(spe.y == spec.y) | ||
assert spe._xdata is spec._xdata | ||
assert spe._ydata is spec._ydata | ||
|
||
spe = rc2.spectrum.Spectrum(x=np.arange(100, dtype=int)) | ||
assert spe._ydata is None | ||
with pytest.raises(ValueError): | ||
spe.y |