Skip to content

Commit

Permalink
add term_names property; closes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
tyarkoni committed Aug 27, 2016
1 parent 6d56b50 commit aa535c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bambi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ def add_term(self, variable, data=None, label=None, categorical=False,
self.terms[term.name] = term
self.built = False

@property
def term_names(self):
return list(self.terms.keys())


class Term(object):

Expand Down
8 changes: 8 additions & 0 deletions bambi/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ def test_model_init_and_intercept(diabetes_data):
assert not model.terms


def test_model_term_names_property(diabetes_data):
model = Model(diabetes_data)
model.add_term('BMI')
model.add_term('BP')
model.add_term('S1')
assert model.term_names == ['BMI', 'BP', 'S1']


def test_add_term_to_model(base_model):

base_model.add_term('BMI')
Expand Down

0 comments on commit aa535c5

Please sign in to comment.