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

merge (and probably transform) fail if same expression is used twice for creating different columns #1325

Closed
podshumok opened this Issue Nov 25, 2015 · 0 comments

Comments

Projects
None yet
2 participants
@podshumok

podshumok commented Nov 25, 2015

Sample code:

x = blaze.Data(...)  # tested with pandas.DataFrame and mysql
blaze.merge(
    a=x.time - x.time % 3,
    b=x.time % 3,
)

Error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/python3.4/site-packages/IPython/core/formatters.py in __call__(self, obj)
    695                 type_pprinters=self.type_printers,
    696                 deferred_pprinters=self.deferred_printers)
--> 697             printer.pretty(obj)
    698             printer.flush()
    699             return stream.getvalue()

/tmp/python3.4/site-packages/IPython/lib/pretty.py in pretty(self, obj)
    381                             if callable(meth):
    382                                 return meth(obj, self, cycle)
--> 383             return _default_pprint(obj, self, cycle)
    384         finally:
    385             self.end_group()

/tmp/python3.4/site-packages/IPython/lib/pretty.py in _default_pprint(obj, p, cycle)
    501     if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs:
    502         # A user-provided repr. Find newlines and replace them with p.break_()
--> 503         _repr_pprint(obj, p, cycle)
    504         return
    505     p.begin_group(1, '<')

/tmp/python3.4/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
    683     """A pprint that just redirects to the normal repr function."""
    684     # Find newlines and replace them with p.break_()
--> 685     output = repr(obj)
    686     for idx,output_line in enumerate(output.splitlines()):
    687         if idx:

/tmp/python3.4/site-packages/blaze/interactive.py in expr_repr(expr, n)
    259     if (ndim(expr) == 1 and (istabular(expr.dshape) or
    260                              isscalar(expr.dshape.measure))):
--> 261         return repr_tables(expr, 10)
    262 
    263     # Smallish arrays

/tmp/python3.4/site-packages/blaze/interactive.py in repr_tables(expr, n)
    198 
    199 def repr_tables(expr, n=10):
--> 200     result = concrete_head(expr, n).rename(columns={None: ''})
    201 
    202     if isinstance(result, (DataFrame, Series)):

/tmp/python3.4/site-packages/blaze/interactive.py in concrete_head(expr, n)
    180         return odo(head, object)
    181     elif isrecord(expr.dshape.measure):
--> 182         return odo(head, DataFrame)
    183     else:
    184         df = odo(head, DataFrame)

/tmp/python3.4/site-packages/odo/odo.py in odo(source, target, **kwargs)
     88     odo.append.append      - Add things onto existing things
     89     """
---> 90     return into(target, source, **kwargs)

/tmp/python3.4/site-packages/multipledispatch/dispatcher.py in __call__(self, *args, **kwargs)
    162             self._cache[types] = func
    163         try:
--> 164             return func(*args, **kwargs)
    165 
    166         except MDNotImplementedError:

/tmp/python3.4/site-packages/blaze/interactive.py in into(a, b, **kwargs)
    303 @dispatch((object, type, str, unicode), Expr)
    304 def into(a, b, **kwargs):
--> 305     result = compute(b, **kwargs)
    306     kwargs['dshape'] = b.dshape
    307     return into(a, result, **kwargs)

/tmp/python3.4/site-packages/multipledispatch/dispatcher.py in __call__(self, *args, **kwargs)
    162             self._cache[types] = func
    163         try:
--> 164             return func(*args, **kwargs)
    165 
    166         except MDNotImplementedError:

/tmp/python3.4/site-packages/blaze/interactive.py in compute(expr, **kwargs)
    165         raise ValueError("No data resources found")
    166     else:
--> 167         return compute(expr, resources, **kwargs)
    168 
    169 

/tmp/python3.4/site-packages/multipledispatch/dispatcher.py in __call__(self, *args, **kwargs)
    162             self._cache[types] = func
    163         try:
--> 164             return func(*args, **kwargs)
    165 
    166         except MDNotImplementedError:

/tmp/python3.4/site-packages/blaze/compute/core.py in compute(expr, d, **kwargs)
    470         d4 = d3
    471 
--> 472     result = top_then_bottom_then_top_again_etc(expr3, d4, **kwargs)
    473     if post_compute_:
    474         result = post_compute_(expr3, result, scope=d4)

/tmp/python3.4/site-packages/blaze/compute/core.py in top_then_bottom_then_top_again_etc(expr, scope, **kwargs)
    175     if optimize_:
    176         try:
--> 177             expr3 = optimize_(expr2, *[scope3[leaf] for leaf in expr2._leaves()])
    178             _d = dict(zip(expr2._leaves(), expr3._leaves()))
    179             scope4 = dict((e._subs(_d), d) for e, d in scope3.items())

/tmp/python3.4/site-packages/blaze/compute/core.py in <listcomp>(.0)
    175     if optimize_:
    176         try:
--> 177             expr3 = optimize_(expr2, *[scope3[leaf] for leaf in expr2._leaves()])
    178             _d = dict(zip(expr2._leaves(), expr3._leaves()))
    179             scope4 = dict((e._subs(_d), d) for e, d in scope3.items())

KeyError: _5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment