MCPcopy
hub / github.com/numpy/numpy / assert_features_equal

Function assert_features_equal

numpy/_core/tests/test_cpu_features.py:17–61  ·  view source on GitHub ↗
(actual, desired, fname)

Source from the content-addressed store, hash-verified

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

Callers 1

test_featuresMethod · 0.85

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…