Skip to content

Commit

Permalink
Rename dummy attribute to relation.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwardrop committed Jul 30, 2018
1 parent 36e9662 commit d00a0e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mensor/backends/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _dataframe_agg(cls, df, unit_type, measures, segment_by, rebase_agg=False,
elif len(segment_by_cols) > 0:
df = (
df
.assign(dummy=1)
.assign(relation=1)
.groupby(segment_by_cols)
.sum()
.reset_index()
Expand Down
4 changes: 2 additions & 2 deletions mensor/measures/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def identifiers(self):
def identifiers(self, identifiers):
self._identifiers = self._get_dimensions_from_specs(_StatisticalUnitIdentifier, identifiers)

def provides_identifier(self, unit_type=None, expr=None, desc=None, role='foreign', dummy=False):
identifier = _StatisticalUnitIdentifier(unit_type, expr=expr, desc=desc, role=role, dummy=dummy, provider=self)
def provides_identifier(self, unit_type=None, expr=None, desc=None, role='foreign', relation=False):
identifier = _StatisticalUnitIdentifier(unit_type, expr=expr, desc=desc, role=role, relation=relation, provider=self)
self._identifiers.append(identifier)
return self

Expand Down
18 changes: 9 additions & 9 deletions mensor/measures/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,13 +702,13 @@ def __init__(self, name, expr=None, default=None, desc=None, shared=False, parti

class _StatisticalUnitIdentifier(_ProvidedFeature):

def __init__(self, name, expr=None, desc=None, role='foreign', dummy=False, provider=None):
_ProvidedFeature.__init__(self, name, expr=expr, desc=desc, shared=not dummy, provider=provider)
def __init__(self, name, expr=None, desc=None, role='foreign', relation=False, provider=None):
_ProvidedFeature.__init__(self, name, expr=expr, desc=desc, shared=not relation, provider=provider)
assert role in ('primary', 'unique', 'foreign')
if dummy:
if relation:
assert role == 'primary', "Dummy identifiers currently only makes sense when it is to be treated as primary."
self.role = role
self._dummy = dummy
self._relation = relation

@property
def unit_type(self):
Expand All @@ -727,9 +727,9 @@ def is_unique(self):
return self.role in ('primary', 'unique')

@property
def is_dummy(self):
def is_relation(self):
"""
If a unit type is a dummy, then it can never be linked to actual data,
If a unit type is a relation, then it can never be linked to actual data,
which has the following consequences:
- The dimensions associated with it can never be used via foreign keys.
- It cannot be used as a member of `segment_by` in an evaluation.
Expand All @@ -741,16 +741,16 @@ def is_dummy(self):
Note that data is still accessible via reverse foreign keys.
"""
return self._dummy
return self._relation

def __repr__(self):
prefix = suffix = ''
if self.is_primary:
prefix = '^'
elif self.is_unique:
prefix = '*'
if self.is_dummy:
suffix += '(d)'
if self.is_relation:
suffix += '(r)'
return prefix + _ProvidedFeature.__repr__(self) + suffix

def matches(self, unit_type, reverse=False):
Expand Down

0 comments on commit d00a0e7

Please sign in to comment.