예제 #1
0
def test():
    """Run object editor test"""
    import datetime
    import numpy as np
    from spyder.pil_patch import Image

    app = qapplication()

    data = np.random.randint(1, 256, size=(100, 100)).astype('uint8')
    image = Image.fromarray(data)

    class Foobar(object):
        def __init__(self):
            self.text = "toto"

        def get_text(self):
            return self.text
    foobar = Foobar()
    example = {'str': 'kjkj kj k j j kj k jkj',
               'list': [1, 3, 4, 'kjkj', None],
               'set': {1, 2, 1, 3, None, 'A', 'B', 'C', True, False},
               'dict': {'d': 1, 'a': np.random.rand(10, 10), 'b': [1, 2]},
               'float': 1.2233,
               'array': np.random.rand(10, 10),
               'image': image,
               'date': datetime.date(1945, 5, 8),
               'datetime': datetime.datetime(1945, 5, 8),
               'foobar': foobar}
    ObjectExplorer.create_explorer(example, 'Example')
예제 #2
0
파일: iofuncs.py 프로젝트: 0xBADCA7/spyder
 def __image_to_array(filename):
     img = Image.open(filename)
     try:
         dtype, extra = DTYPES[img.mode]
     except KeyError:
         raise RuntimeError("%s mode is not supported" % img.mode)
     shape = (img.size[1], img.size[0])
     if extra is not None:
         shape += (extra,)
     return np.array(img.getdata(), dtype=np.dtype(dtype)).reshape(shape)
예제 #3
0
 def __image_to_array(filename):
     img = Image.open(filename)
     try:
         dtype, extra = DTYPES[img.mode]
     except KeyError:
         raise RuntimeError("%s mode is not supported" % img.mode)
     shape = (img.size[1], img.size[0])
     if extra is not None:
         shape += (extra, )
     return np.array(img.getdata(), dtype=np.dtype(dtype)).reshape(shape)