-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use scooby for Versions #792
Merged
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
134c4fe
Use scooby for Versions
prisae 502ba27
Provide all args
prisae 5f6667a
Explicit args pasing
prisae 748b280
Make scooby a soft dep; Versions->Report
prisae a18d8ed
Move to codeutils
prisae da25600
Typo
prisae a70cd1d
Simpler way for `requires_module`
prisae a4a2201
typo
prisae b882a5e
Avoid name clash
prisae c435993
Merge branch 'master' into scooby
prisae 071f3a5
Add conda-forge possibility
prisae 743f380
Fix wrong bracket
prisae 0f83e38
Merge branch 'simulation' into scooby
jcapriot File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ wheel | |
pytest | ||
jupyter | ||
sphinxcontrib-napoleon | ||
scooby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,24 @@ | ||
import pip | ||
import scooby | ||
import unittest | ||
import sys | ||
import io | ||
|
||
# Optional imports | ||
try: | ||
import IPython | ||
except ImportError: | ||
IPython = False | ||
|
||
from SimPEG import Versions | ||
|
||
|
||
class TestVersion(unittest.TestCase): | ||
|
||
def catch_version_stdout(self, *args, **kwargs): | ||
|
||
# Check the default | ||
stdout = sys.stdout | ||
sys.stdout = io.StringIO() | ||
|
||
# Print text version | ||
print(Versions(*args, **kwargs).__repr__()) | ||
|
||
# catch the output | ||
out1 = sys.stdout.getvalue() | ||
sys.stdout = stdout | ||
|
||
# Check the default | ||
stdout = sys.stdout | ||
sys.stdout = io.StringIO() | ||
|
||
# Print html version | ||
print(Versions(*args, **kwargs)._repr_html_()) | ||
|
||
# catch the output | ||
out2 = sys.stdout.getvalue() | ||
sys.stdout = stdout | ||
|
||
return out1, out2 | ||
|
||
def test_version_defaults(self): | ||
|
||
# Check the default | ||
out1_text, out1_html = self.catch_version_stdout(pip) | ||
|
||
# Check one of the standard packages | ||
assert 'numpy' in out1_text | ||
assert 'numpy' in out1_html | ||
|
||
# Providing a package as a tuple | ||
out2_text, out2_html = self.catch_version_stdout(add_pckg=(pip,)) | ||
|
||
# Check the provided package, with number | ||
assert pip.__version__ + ' : pip' in out2_text | ||
assert pip.__version__ in out2_html | ||
assert ">pip</td>" in out2_html | ||
|
||
# Providing a package as a list | ||
out3_text, out3_html = self.catch_version_stdout(add_pckg=[pip]) | ||
|
||
assert 'numpy' in out3_text | ||
assert 'td style=' in out3_html | ||
|
||
# Check row of provided package, with number | ||
teststr = "<td style='text-align: right; background-color: #ccc; " | ||
teststr += "border: 2px solid #fff;'>" | ||
teststr += pip.__version__ | ||
teststr += "</td>\n <td style='" | ||
teststr += "text-align: left; border: 2px solid #fff;'>pip</td>" | ||
assert teststr in out3_html | ||
# Reporting is now done by the external package scooby. | ||
# We just ensure the shown packages do not change (core and optional). | ||
out1 = Versions() | ||
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:] | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of making this a soft dependency? Since it isn't strictly necessary for running simulations or inversions with SimPEG, I would be inclined to make it a soft rather than a hard dependency