Skip to content
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

Improves error handling when "shear" but no metadata passed #525

Merged
merged 5 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jstest:
stylecheck:
jshint $(JSLOCS)
prettier --check --tab-width 4 $(JSLOCS) $(CSSLOCS)
flake8 empress/*.py tests/python/*.py setup.py
flake8 empress/*.py tests/python/*.py setup.py empress/scripts/*.py

# Auto-formats the JS code
jsstyle:
Expand Down
5 changes: 5 additions & 0 deletions empress/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ def __init__(self, tree, table=None, sample_metadata=None,
# self._validate_and_match_data()
self.features = feature_metadata.copy()
else:
if shear_to_feature_metadata:
raise ValueError(
"Feature metadata must be provided in order to shear "
"to feature metadata."
)
self.features = None

self.ordination = ordination
Expand Down
2 changes: 2 additions & 0 deletions empress/scripts/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ def empress():
"""Generates an interactive visualization of a phylogenetic tree."""
pass


# Allow using -h to show help information
# https://click.palletsprojects.com/en/7.x/documentation/#help-parameter-customization
CTXSETS = {"help_option_names": ["-h", "--help"]}


@empress.command(
"tree-plot", short_help=desc.TREE_PLOT_DESC, context_settings=CTXSETS
)
Expand Down
5 changes: 5 additions & 0 deletions tests/python/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ def test_init_tree_plot_fm_not_matching(self):
):
Empress(self.tree, feature_metadata=bad_fm)

def test_init_tree_plot_shear_without_metadata(self):
with self.assertRaisesRegex(ValueError,
"Feature metadata must be provided"):
Empress(self.tree, shear_to_feature_metadata=True)

def test_init_only_one_of_table_and_sm_passed(self):
exp_errmsg = (
"Both the table and sample metadata should be specified or None. "
Expand Down