Skip to content

Deepcopy an sframe #85

Description

@sb2nov
import sframe
sf = sframe.SFrame()
sf['a'] = [1,1,1,1,             2,2,2,           3,     4,4,      5]
sf['b'] = [1,2,1,2,             3,3,1,           4,     None, 2,  3]
sf2= deepcopy(sf)

Error logs


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-f0d0a6912fba> in <module>()
----> 1 sf2= deepcopy(sf)

/Users/sbajaj/miniconda/lib/python2.7/copy.pyc in deepcopy(x, memo, _nil)
    188                             raise Error(
    189                                 "un(deep)copyable object of type %s" % cls)
--> 190                 y = _reconstruct(x, rv, 1, memo)
    191 
    192     memo[d] = y

/Users/sbajaj/miniconda/lib/python2.7/copy.pyc in _reconstruct(x, info, deep, memo)
    332     if state:
    333         if deep:
--> 334             state = deepcopy(state, memo)
    335         if hasattr(y, '__setstate__'):
    336             y.__setstate__(state)

/Users/sbajaj/miniconda/lib/python2.7/copy.pyc in deepcopy(x, memo, _nil)
    161     copier = _deepcopy_dispatch.get(cls)
    162     if copier:
--> 163         y = copier(x, memo)
    164     else:
    165         try:

/Users/sbajaj/miniconda/lib/python2.7/copy.pyc in _deepcopy_tuple(x, memo)
    235     y = []
    236     for a in x:
--> 237         y.append(deepcopy(a, memo))
    238     d = id(x)
    239     try:

/Users/sbajaj/miniconda/lib/python2.7/copy.pyc in deepcopy(x, memo, _nil)
    161     copier = _deepcopy_dispatch.get(cls)
    162     if copier:
--> 163         y = copier(x, memo)
    164     else:
    165         try:

/Users/sbajaj/miniconda/lib/python2.7/copy.pyc in _deepcopy_dict(x, memo)
    255     memo[id(x)] = y
    256     for key, value in x.iteritems():
--> 257         y[deepcopy(key, memo)] = deepcopy(value, memo)
    258     return y
    259 d[dict] = _deepcopy_dict

/Users/sbajaj/miniconda/lib/python2.7/copy.pyc in deepcopy(x, memo, _nil)
    188                             raise Error(
    189                                 "un(deep)copyable object of type %s" % cls)
--> 190                 y = _reconstruct(x, rv, 1, memo)
    191 
    192     memo[d] = y

/Users/sbajaj/miniconda/lib/python2.7/copy.pyc in _reconstruct(x, info, deep, memo)
    327     if deep:
    328         args = deepcopy(args, memo)
--> 329     y = callable(*args)
    330     memo[id(x)] = y
    331 

/Users/sbajaj/miniconda/lib/python2.7/copy_reg.pyc in __newobj__(cls, *args)
     91 
     92 def __newobj__(cls, *args):
---> 93     return cls.__new__(cls, *args)
     94 
     95 def _slotnames(cls):

sframe/cython/cy_sframe.pyx in sframe.cython.cy_sframe.UnitySFrameProxy.__cinit__()

TypeError: __cinit__() takes at least 1 positional argument (0 given)

Activity

  1. ylow commented on Nov 13, 2015

    @ylow

    Copy should be fine. Either sf.copy() or copy.copy(sf).

    Since SArrays are immutable, copy is sufficient.

  2. hoytak commented on Nov 13, 2015

    @hoytak
    Contributor

    @ylow: Yes, but we should support the __deepcopy__ method so the above works correctly.

  3. self-assigned this
    on Nov 13, 2015
  4. added this to the 15-12 Update milestone on Dec 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions