MCPcopy Create free account
hub / github.com/numpy/numpy / assert_features_equal

Function assert_features_equal

numpy/core/tests/test_cpu_features.py:13–58  ·  view source on GitHub ↗
(actual, desired, fname)

Source from the content-addressed store, hash-verified

11import re
12
13def assert_features_equal(actual, desired, fname):
14 __tracebackhide__ = True # Hide traceback for py.test
15 actual, desired = str(actual), str(desired)
16 if actual == desired:
17 return
18 detected = str(__cpu_features__).replace("'", "")
19 try:
20 with open("/proc/cpuinfo") as fd:
21 cpuinfo = fd.read(2048)
22 except Exception as err:
23 cpuinfo = str(err)
24
25 try:
26 import subprocess
27 auxv = subprocess.check_output(['/bin/true'], env=dict(LD_SHOW_AUXV="1"))
28 auxv = auxv.decode()
29 except Exception as err:
30 auxv = str(err)
31
32 import textwrap
33 error_report = textwrap.indent(
34"""
35###########################################
36### Extra debugging information
37###########################################
38-------------------------------------------
39--- NumPy Detections
40-------------------------------------------
41%s
42-------------------------------------------
43--- SYS / CPUINFO
44-------------------------------------------
45%s....
46-------------------------------------------
47--- SYS / AUXV
48-------------------------------------------
49%s
50""" % (detected, cpuinfo, auxv), prefix='\r')
51
52 raise AssertionError((
53 "Failure Detection\n"
54 " NAME: '%s'\n"
55 " ACTUAL: %s\n"
56 " DESIRED: %s\n"
57 "%s"
58 ) % (fname, actual, desired, error_report))
59
60def _text_to_list(txt):
61 out = txt.strip("][\n").replace("'", "").split(', ')

Callers 1

test_featuresMethod · 0.85

Calls 5

openFunction · 0.85
replaceMethod · 0.80
decodeMethod · 0.80
readMethod · 0.45
check_outputMethod · 0.45

Tested by

no test coverage detected