def generate_report(additional=None, ncol=3, text_width=54, sort=False): """DEPRECATED: Please use :class:`pyvista.Report` instead.""" logging.warning('DEPRECATED: Please use `pyvista.Report` instead.') core = ['pyvista', 'vtk', 'numpy', 'imageio', 'appdirs', 'scooby'] optional = ['matplotlib', 'PyQt5', 'IPython', 'ipywidgets', 'colorcet', 'cmocean'] report = scooby.Report(core=core, optional=optional, additional=additional, ncol=ncol, text_width=text_width, sort=sort) return report
def test_plain_vs_html(): report = scooby.Report() text_html = BeautifulSoup(report._repr_html_()).get_text() text_plain = report.__repr__() text_plain = " ".join(re.findall("[a-zA-Z1-9]+", text_plain)) text_html = " ".join(re.findall("[a-zA-Z1-9]+", text_html)) # Plain text currently starts with `Date :`; # we should remove that, or add it to the html version too. assert text_html == text_plain[5:]
def test_report(capsys): out, _ = capsys.readouterr() # Empty capsys # Reporting is done by the external package scooby. # We just ensure the shown packages do not change (core and optional). if scooby: out1 = utils.Report() out2 = scooby.Report(core=['numpy', 'scipy', 'pylops'], optional=['IPython', 'matplotlib', 'numba']) # Ensure they're the same; exclude time to avoid errors. assert out1.__repr__()[115:] == out2.__repr__()[115:] else: # soft dependency _ = utils.Report() out, _ = capsys.readouterr() # Empty capsys assert 'NOTE: `pylops.Report` requires `scooby`. Install it via' in out
def test_report(capsys): out, _ = capsys.readouterr() # Empty capsys # Reporting is now done by the external package scooby. # We just ensure the shown packages do not change (core and optional). if scooby: out1 = scooby.Report(core=['numpy', 'scipy', 'numba', 'empymod'], optional=['IPython', 'matplotlib'], ncol=3) out2 = utils.Report() # Ensure they're the same; exclude time to avoid errors. assert out1.__repr__()[115:] == out2.__repr__()[115:] else: # soft dependency _ = utils.Report() out, _ = capsys.readouterr() # Empty capsys assert 'WARNING :: `empymod.Report` requires `scooby`' in out
def test_extra_meta(): report = scooby.Report(extra_meta=("key", "value")) assert "key : value" in report.__repr__() report = scooby.Report(extra_meta=(("key", "value"), )) assert "key : value" in report.__repr__() report = scooby.Report(extra_meta=(("key", "value"), ("another", "one"))) assert "key : value" in report.__repr__() assert "another : one" in report.__repr__() with pytest.raises(TypeError): report = scooby.Report(extra_meta=(("key", "value"), "foo")) with pytest.raises(TypeError): report = scooby.Report(extra_meta="foo") with pytest.raises(TypeError): report = scooby.Report(extra_meta="fo")
def test_Report(capsys): out, _ = capsys.readouterr() # Empty capsys # Reporting is now done by the external package scooby. # We just ensure the shown packages do not change (core and optional). if scooby: out1 = utils.Report() out2 = scooby.Report(core=['numpy', 'scipy', 'numba', 'emg3d'], optional=[ 'empymod', 'xarray', 'discretize', 'h5py', 'matplotlib', 'tqdm', 'IPython' ], ncol=4) # Ensure they're the same; exclude time to avoid errors. assert out1.__repr__()[115:] == out2.__repr__()[115:] else: # soft dependency with pytest.warns(UserWarning, match='emg3d: This feature requires'): _ = utils.Report()
def test_version_defaults(self): # Reporting is now done by the external package scooby. # We just ensure the shown packages do not change (core and optional). out1 = Report() out2 = scooby.Report( core=[ "SimPEG", "discretize", "pymatsolver", "vectormath", "properties", "numpy", "scipy", "cython", ], optional=["IPython", "matplotlib", "ipywidgets"], ncol=4, ) # Ensure they're the same; exclude initial time to avoid errors due # to second-change. assert out1.__repr__()[115:] == out2.__repr__()[115:]
def test_report(): report = scooby.Report() text = str(report) assert len(text) > 0 assert len(report.packages) > 0 for pkg, vers in report.packages.items(): assert isinstance(pkg, str) assert isinstance(vers, str) report = scooby.Report(core='numpy') assert ('numpy' in report.packages) html = report._repr_html_() assert len(html) > 0 # Same as what is printed in Travis build log report = scooby.Report(additional=['mock', 'foo']) report = scooby.Report(additional=[ 'foo', ]) report = scooby.Report(additional=[ mock, ]) report = scooby.Report(additional=mock) report = scooby.Report(additional=['collections', 'foo', 'aaa'], sort=True)
def test_dict(): report = scooby.Report(['no_version', 'does_not_exist']) for key, value in report.to_dict().items(): if key is not 'MKL': assert key in report.__repr__() assert value[:10] in report.__repr__()