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

Method check_output

tools/refguide_check.py:682–757  ·  view source on GitHub ↗
(self, want, got, optionflags)

Source from the content-addressed store, hash-verified

680 self.ns = ns
681
682 def check_output(self, want, got, optionflags):
683 # cut it short if they are equal
684 if want == got:
685 return True
686
687 # skip stopwords in source
688 if any(word in self._source for word in self.stopwords):
689 return True
690
691 # skip random stuff
692 if any(word in want for word in self.rndm_markers):
693 return True
694
695 # skip function/object addresses
696 if self.obj_pattern.search(got):
697 return True
698
699 # ignore comments (e.g. signal.freqresp)
700 if want.lstrip().startswith("#"):
701 return True
702
703 # try the standard doctest
704 try:
705 if self.vanilla.check_output(want, got, optionflags):
706 return True
707 except Exception:
708 pass
709
710 # OK then, convert strings to objects
711 try:
712 a_want = eval(want, dict(self.ns))
713 a_got = eval(got, dict(self.ns))
714 except Exception:
715 # Maybe we're printing a numpy array? This produces invalid python
716 # code: `print(np.arange(3))` produces "[0 1 2]" w/o commas between
717 # values. So, reinsert commas and retry.
718 # TODO: handle (1) abberivation (`print(np.arange(10000))`), and
719 # (2) n-dim arrays with n > 1
720 s_want = want.strip()
721 s_got = got.strip()
722 cond = (s_want.startswith("[") and s_want.endswith("]") and
723 s_got.startswith("[") and s_got.endswith("]"))
724 if cond:
725 s_want = ", ".join(s_want[1:-1].split())
726 s_got = ", ".join(s_got[1:-1].split())
727 return self.check_output(s_want, s_got, optionflags)
728
729 if not self.parse_namedtuples:
730 return False
731 # suppose that "want" is a tuple, and "got" is smth like
732 # MoodResult(statistic=10, pvalue=0.1).
733 # Then convert the latter to the tuple (10, 0.1),
734 # and then compare the tuples.
735 try:
736 num = len(a_want)
737 regex = (r'[\w\d_]+\(' +
738 ', '.join([r'[\w\d_]+=(.+)']*num) +
739 r'\)')

Callers 15

mainFunction · 0.45
setup.pyFile · 0.45
assert_features_equalFunction · 0.45
load_flags_auxvMethod · 0.45
test_limited_apiFunction · 0.45
test_import_lazy_importFunction · 0.45
test_f2pyFunction · 0.45
test_pep338Function · 0.45
UnixCCompiler__compileFunction · 0.45
CCompiler_spawnFunction · 0.45
CCompiler_get_versionFunction · 0.45

Calls 10

_do_checkMethod · 0.95
startswithMethod · 0.80
lstripMethod · 0.80
stripMethod · 0.80
endswithMethod · 0.80
replaceMethod · 0.80
anyFunction · 0.50
allFunction · 0.50
joinMethod · 0.45
splitMethod · 0.45

Tested by 10

mainFunction · 0.36
assert_features_equalFunction · 0.36
load_flags_auxvMethod · 0.36
test_limited_apiFunction · 0.36
test_import_lazy_importFunction · 0.36
test_f2pyFunction · 0.36
test_pep338Function · 0.36
test_build_importFunction · 0.36
runnerFunction · 0.36