numexpr
numexpr copied to clipboard
Fix handling of numexpr.cpu in print_versions()
There are a couple of issues in the way numexpr.cpu.info is used in print_versions():
- all the subclasses of
CPUInfoBasehave a class attributeinfo, whereasCPUInfoBasedoes not; this means that, in case there is no CPU implementation for an OS,self.inforeturns a function (because ofCPUInfoBase.__getattr__()) which is not subscriptable - only few subclasses of
CPUInfoBase(e.g.LinuxCPUInfo,Win32CPUInfo) implementinfoas list of dicts for each CPU, whereas the rest of the implementations use a dict with attributes
Since info seems to be mostly an internal detail, then adapt print_versions() to be a little more flexible:
- do not try to query attributes in case the actual CPU implementation is
CPUInfoBase: it is not implemented for the current OS, so there is nothing to query anyway (fixes (1)) - get the first element of
infoonly in case it is a list (fixes (2)) - drop the catch of
KeyError, which should not happen anymore now