sofar 1.1.2__py2.py3-none-any.whl → 1.1.4__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sofar/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  __author__ = """The pyfar developers"""
6
6
  __email__ = 'info@pyfar.org'
7
- __version__ = '1.1.2'
7
+ __version__ = '1.1.4'
8
8
 
9
9
  from .sofa import Sofa
10
10
 
sofar/sofa.py CHANGED
@@ -73,7 +73,7 @@ class Sofa():
73
73
 
74
74
 
75
75
  For more examples refer to the `Quick tour of SOFA and sofar` at
76
- https://sofar.readthedocs.io/en/latest/
76
+ https://sofar.readthedocs.io/en/stable/
77
77
  """
78
78
 
79
79
  # these have to be set here, because they are used in __setattr__ and
@@ -992,18 +992,17 @@ class Sofa():
992
992
  f"- {key} must be string but is {type(value)}\n"
993
993
 
994
994
  elif dtype == "double":
995
- # multiple checks needed because sofar does not force the user
996
- # to initally pass data as numpy arrays
997
- if not isinstance(value,
998
- (np.int_, np.float_, np.double, np.ndarray)):
999
- current_error += (f"- {key} must be int, float or numpy "
1000
- f"array but is {type(value)}\n")
1001
-
1002
- if isinstance(value, np.ndarray) and not (
1003
- str(value.dtype).startswith('int') or
1004
- str(value.dtype).startswith('float')):
995
+ # All variables can be of type float or int, and are converted
996
+ # to float when writing.
997
+ # sofar does not force the user to pass data as numpy arrays.
998
+ # We thus check for allowed instances (int, float, numpy) and
999
+ # specifically for the type of numpy arrays.
1000
+ if not isinstance(
1001
+ value, (int, float, np.ndarray, np.number)) or \
1002
+ (isinstance(value, (np.ndarray, np.number)) and
1003
+ value.dtype.kind not in ['i', 'f']):
1005
1004
  current_error += (f"- {key} must be int or float "
1006
- f"but is {type(value.dtype)}\n")
1005
+ f"but is {type(value)}\n")
1007
1006
 
1008
1007
  elif dtype == "string":
1009
1008
  # multiple checks needed because sofar does not force the user
@@ -1,5 +1,6 @@
1
1
  import contextlib
2
2
  import os
3
+ import re
3
4
  import glob
4
5
  import json
5
6
  import requests
@@ -377,13 +378,9 @@ def _check_congruency(save_dir=None, branch="master"):
377
378
 
378
379
  # get file names of conventions from github
379
380
  url = urls_check[1]
380
- page = requests.get(url).json()
381
- sofatoolbox = []
382
- for content in page["payload"]["tree"]["items"]:
383
- if content["contentType"] == "file" and \
384
- content["path"].startswith("SOFAtoolbox/conventions") and \
385
- content["name"].endswith("csv"):
386
- sofatoolbox.append(content["name"])
381
+ page = requests.get(url).text
382
+ sofatoolbox = re.findall(
383
+ r'"SOFAtoolbox/conventions/([^"]+\.csv)"', page)
387
384
 
388
385
  if not sofatoolbox:
389
386
  raise ValueError(f"Did not find any conventions at {url}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sofar
3
- Version: 1.1.2
3
+ Version: 1.1.4
4
4
  Summary: Maybe the most complete python package for SOFA files so far
5
5
  Home-page: https://pyfar.org/
6
6
  Download-URL: https://pypi.org/project/sofar/
@@ -75,7 +75,7 @@ Refer to the `contribution guidelines`_ for more information.
75
75
  .. _sofa_conventions : https://github.com/pyfar/sofa_conventions
76
76
  .. _contribution guidelines: https://github.com/pyfar/sofar/blob/develop/CONTRIBUTING.rst
77
77
  .. _pyfar.org: https://pyfar.org
78
- .. _read the docs: https://sofar.readthedocs.io/en/latest
78
+ .. _read the docs: https://sofar.readthedocs.io/en/stable
79
79
  .. _sofaconventions.org: https://sofaconventions.org
80
80
 
81
81
  References
@@ -1,7 +1,7 @@
1
- sofar/__init__.py,sha256=RGIpbxH5bVZKn19hx98TkmvdckxJhAWnp1HHSrTq35A,595
1
+ sofar/__init__.py,sha256=ipQxAym8ywA7KcX4SVQOlutZ0fV2cCt7U294geEFmL0,595
2
2
  sofar/io.py,sha256=XdkfG6jo4RI8JqUgXEfx2ka06_CfffPJXs0HqeMSri0,15761
3
- sofar/sofa.py,sha256=QVr0UKr-aqo2K7_PEHtXk9VuvrjE36QgcYIqFJ6KBrc,68255
4
- sofar/update_conventions.py,sha256=36ba0cAVtKppJCrsEhP2aiv1DGEtxNx06hsUAERDlwM,16753
3
+ sofar/sofa.py,sha256=RxR9JP0U5RXK_b3eyzWAQkYKyLKaKLRh8cwBdnE4hS8,68238
4
+ sofar/update_conventions.py,sha256=AwIihKYk0ZeNnXe_5dawJiMtqcCGSjPcDHwcrAIRiI4,16551
5
5
  sofar/utils.py,sha256=0JwYLLyVu1ZcAfUQKSucywcQPlHB2Ojez7fxIXhuaFw,10754
6
6
  sofar/sofa_conventions/VERSION,sha256=IuQRql5P3qfPUQuJwuh-RX5TvI_Wd4bDdSm8VLNQqds,34
7
7
  sofar/sofa_conventions/conventions/FreeFieldDirectivityTF_1.1.csv,sha256=Wait37FTh6ROKgpX7-JsVM-ohtKfsdHjxVL5vN7uTTs,5510
@@ -65,11 +65,11 @@ tests/test_deprecations.py,sha256=coHOEq5XUquYxRge8XKeg005M84wcgSHTEE--CoEar4,58
65
65
  tests/test_io.py,sha256=xMBdWP3vdnk_6aYAhg30nEgGvPfYm30a1qouGHIwRNo,11808
66
66
  tests/test_sofa.py,sha256=DpiI517T-gLoajy9nQCHT7ouxM40JwirsqkVMFT5cWo,11314
67
67
  tests/test_sofa_upgrade_conventions.py,sha256=HqIuvFFub1_HCH6qHTLPcPyBZ2ayDKzmZR7RwnTxo_o,3377
68
- tests/test_sofa_verify.py,sha256=cleTkFJurJfDEZrnSTfBYe2VqsCZ1VxWr9efNGjWr88,15631
68
+ tests/test_sofa_verify.py,sha256=W2BbhGn61yM0qwGMlrwUweO6zIcvcL5bcf5KZw1cSTk,15834
69
69
  tests/test_utils.py,sha256=yT290xCaeDW4l3DHUeFGiVmLe9xMguETN1NAGRTJ-X4,8307
70
- sofar-1.1.2.dist-info/AUTHORS.rst,sha256=JGcf9PJwl0w14PgTRjI3HXpcwDbkGbUN4mkYoZ8smL8,164
71
- sofar-1.1.2.dist-info/LICENSE,sha256=qdGH_RUPveBBfGYShm6OIBd6bRJdwp3fDCpjMsowmqA,1068
72
- sofar-1.1.2.dist-info/METADATA,sha256=e8jmS10i7hzFk7nLcG5YLzrSKrhahvx7U9sLmMicx6Q,3242
73
- sofar-1.1.2.dist-info/WHEEL,sha256=-G_t0oGuE7UD0DrSpVZnq1hHMBV9DD2XkS5v7XpmTnk,110
74
- sofar-1.1.2.dist-info/top_level.txt,sha256=2JSMmeQ5zeMumFynTJU1oODh09wxSiN3gFpsY-bNsSo,12
75
- sofar-1.1.2.dist-info/RECORD,,
70
+ sofar-1.1.4.dist-info/AUTHORS.rst,sha256=JGcf9PJwl0w14PgTRjI3HXpcwDbkGbUN4mkYoZ8smL8,164
71
+ sofar-1.1.4.dist-info/LICENSE,sha256=qdGH_RUPveBBfGYShm6OIBd6bRJdwp3fDCpjMsowmqA,1068
72
+ sofar-1.1.4.dist-info/METADATA,sha256=OkEVBU87yhOOj9g-osLcFSsjd_vCP2dJ12RcfTaBwJM,3242
73
+ sofar-1.1.4.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
74
+ sofar-1.1.4.dist-info/top_level.txt,sha256=2JSMmeQ5zeMumFynTJU1oODh09wxSiN3gFpsY-bNsSo,12
75
+ sofar-1.1.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
tests/test_sofa_verify.py CHANGED
@@ -6,6 +6,7 @@ from glob import glob
6
6
  import pytest
7
7
  from pytest import raises
8
8
  import numpy as np
9
+ import warnings
9
10
 
10
11
  # get verification rules
11
12
  _, unit_aliases, _, _ = sf.Sofa._verification_rules()
@@ -82,19 +83,25 @@ def test_issue_handling(capfd):
82
83
  sf.Sofa._verify_handle_issues(
83
84
  warning_msg, error_msg + "error", issue_handling)
84
85
 
85
- # report warning
86
- issue_handling = "report"
87
- with pytest.warns(None) as warning:
86
+ # print warning
87
+ issue_handling = "print"
88
+ with warnings.catch_warnings():
89
+ warnings.simplefilter('error')
88
90
  _, issues = sf.Sofa._verify_handle_issues(
89
91
  warning_msg + "warning", error_msg, issue_handling)
92
+ out, _ = capfd.readouterr()
90
93
  assert "warning" in issues
94
+ assert 'warning' in out
91
95
  assert "ERROR" not in issues
92
- assert len(warning) == 0
93
- # report error
96
+ assert "ERROR" not in out
97
+ # print error
94
98
  _, issues = sf.Sofa._verify_handle_issues(
95
99
  warning_msg, error_msg + "error", issue_handling)
100
+ out, _ = capfd.readouterr()
96
101
  assert "error" in issues
102
+ assert 'error' in out
97
103
  assert "WARNING" not in issues
104
+ assert "WARNING" not in out
98
105
 
99
106
  # test invalid data for netCDF attribute
100
107
  issue_handling = "ignore"
@@ -185,11 +192,11 @@ def test_data_types(capfd):
185
192
  sofa.verify()
186
193
 
187
194
  sofa.Data_IR = "1"
188
- with raises(ValueError, match="- Data_IR must be int, float"):
195
+ with raises(ValueError, match="- Data_IR must be int or float"):
189
196
  sofa.verify()
190
197
 
191
198
  sofa.Data_IR = 1+1j
192
- with raises(ValueError, match="- Data_IR must be int, float"):
199
+ with raises(ValueError, match="- Data_IR must be int or float"):
193
200
  sofa.verify()
194
201
 
195
202
  # test invalid data with issue_handling "print" and "return"
File without changes