Skip to content

Commit

Permalink
ENH: update aliasedmixin repr
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Jevnik committed Oct 4, 2016
1 parent 09f5fb9 commit ad9120c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion tests/pipeline/test_alias.py
Expand Up @@ -29,9 +29,18 @@ def test_alias(self):
def test_repr(self):
assert_equal(
repr(self.Term().alias('ayy lmao')),
"Aliased%s(..., name='ayy lmao')" % self.Term.__base__.__name__,
"Aliased%s(Term(...), name='ayy lmao')" % (
self.Term.__base__.__name__,
),
)

def test_short_repr(self):
for name in ('a', 'b'):
assert_equal(
self.Term().alias(name).short_repr(),
name,
)


class TestFactorAlias(WithAlias, BasePipelineTestCase):
class Term(Factor):
Expand Down
6 changes: 5 additions & 1 deletion zipline/pipeline/mixins.py
Expand Up @@ -272,11 +272,15 @@ def _compute(self, inputs, dates, assets, mask):
return inputs[0]

def __repr__(self):
return '{type}(..., name={name!r})'.format(
return '{type}({inner_type}(...), name={name!r})'.format(
type=type(self).__name__,
inner_type=type(self.inputs[0]).__name__,
name=self.name,
)

def short_repr(self):
return self.name

@classmethod
def make_aliased_type(cls, other_base):
"""
Expand Down

0 comments on commit ad9120c

Please sign in to comment.