-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 #4102 from andfoy/matlab_import_test
PR: Added Matlab files import tests
- v6.0.4
- v6.0.4rc1
- v6.0.3
- v6.0.3rc2
- v6.0.3rc1
- v6.0.2
- v6.0.2rc1
- v6.0.1
- v6.0.0
- v6.0.0rc2
- v6.0.0rc1
- v6.0.0b3
- v6.0.0b2
- v6.0.0b1
- v6.0.0a5
- v6.0.0a4
- v6.0.0a3
- v6.0.0a2
- v6.0.0a1
- v5.5.6
- v5.5.5
- v5.5.4
- v5.5.3
- v5.5.2
- v5.5.1
- v5.5.0
- v5.4.5
- v5.4.4
- v5.4.3
- v5.4.2
- v5.4.1
- v5.4.0
- v5.3.3
- v5.3.2
- v5.3.1
- v5.3.0
- v5.2.2
- v5.2.1
- v5.2.0
- v5.1.5
- v5.1.4
- v5.1.3
- v5.1.2
- v5.1.1
- v5.1.0
- v5.0.5
- v5.0.4
- v5.0.3
- v5.0.2
- v5.0.1
- v5.0.0
- v5.0.0a7
- v5.0.0a6
- v5.0.0a5
- v5.0.0a4
- v5.0.0a3
- v5.0.0a2
- v5.0.0a1
- v4.2.5
- v4.2.4
- v4.2.3
- v4.2.2
- v4.2.1
- v4.2.0
- v4.1.6
- v4.1.5
- v4.1.4
- v4.1.3
- v4.1.2
- v4.1.1
- v4.1.0
- v4.0.1
- v4.0.0
- v4.0.0rc3
- v4.0.0rc2
- v4.0.0rc1
- v4.0.0b7
- v4.0.0b6
- v4.0.0b5
- v4.0.0b4
- v4.0.0b3
- v4.0.0b2
- v4.0.0b1
- v3.3.6
- v3.3.5
- v3.3.4
- v3.3.3
- v3.3.2
- v3.3.1
- v3.3.0
- v3.2.8
- v3.2.7
- v3.2.6
- v3.2.5
- v3.2.4
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.4
- v3.1.3
Showing
6 changed files
with
61 additions
and
3 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
Binary file not shown.
Binary file not shown.
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,58 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright © Spyder Project Contributors | ||
# Licensed under the terms of the MIT License | ||
# | ||
|
||
""" | ||
Tests for iofuncs.py | ||
""" | ||
|
||
import os | ||
import pytest | ||
import numpy as np | ||
import spyder.utils.iofuncs as io | ||
|
||
LOCATION = os.path.realpath(os.path.join(os.getcwd(), | ||
os.path.dirname(__file__))) | ||
|
||
|
||
@pytest.fixture | ||
def real_values(): | ||
""" | ||
Load a Numpy pickled file. | ||
The file numpy_data.npz contains six variables, each one represents the | ||
expected test values after a manual conversion of the same variables | ||
defined and evaluated in MATLAB. The manual type conversion was done | ||
over several variable types, such as: Matrices/Vectors, Scalar and | ||
Complex numbers, Structs, Strings and Cell Arrays. The set of variables | ||
was defined to allow and test the deep conversion of a compound type, | ||
i.e., a struct that contains other types that need to be converted, | ||
like other structs, matrices and Cell Arrays. | ||
""" | ||
path = os.path.join(LOCATION, 'numpy_data.npz') | ||
file_s = np.load(path) | ||
A = file_s['A'].item() | ||
B = file_s['B'] | ||
C = file_s['C'] | ||
D = file_s['D'].item() | ||
E = file_s['E'] | ||
return {'A':A, 'B':B, 'C':C, 'D':D, 'E':E} | ||
|
||
def test_matlab_import(real_values): | ||
""" | ||
Test the automatic conversion and import of variables from MATLAB. | ||
This test loads a file stored in MATLAB, the variables defined are | ||
equivalent to the manually converted values done over Numpy. This test | ||
allows to evaluate the function which processes the conversion automa- | ||
tically. i.e., The automatic conversion results should be equal to the | ||
manual conversion of the variables. | ||
""" | ||
path = os.path.join(LOCATION, 'data.mat') | ||
inf, _ = io.load_matlab(path) | ||
valid = True | ||
for var in sorted(real_values.keys()): | ||
valid = valid and bool(np.mean(real_values[var] == inf[var])) | ||
assert valid |