示例#1
0
from __future__ import division, print_function
import __common__
(print, print_, print_on, print_off,
 rrr, profile) = __common__.init(__name__, '[pref]')
# Python
import cPickle
import os.path
import sys
import tools
import traceback
import warnings
# Science
import numpy as np
# Qt
from PyQt4 import QtCore, QtGui
from PyQt4.Qt import (QAbstractItemModel, QModelIndex, QVariant, QWidget,
                      QString, Qt, QObject, pyqtSlot)
# HotSpotter
from Printable import DynStruct

# ---
# GLOBALS
# ---
PrefNode = DynStruct


def printDBG(msg):
    #print('[PREFS] '+msg)
    pass

示例#2
0
from __future__ import division, print_function
import __common__
(print, print_, print_on, print_off, rrr,
 profile) = __common__.init(__name__, '[Printable]')
# Standard
import re
import copy
# Scientific
import numpy as np

MAX_VALSTR = -1
#100000


class AbstractPrintable(object):
    'A base class that prints its attributes instead of the memory address'

    def __init__(self, child_print_exclude=[]):
        self._printable_exclude = ['_printable_exclude'] + child_print_exclude

    def __str__(self):
        head = printableType(self)
        body = self.get_printable(type_bit=True)
        body = re.sub('\n *\n *\n', '\n\n', body)
        return head + ('\n' + body).replace('\n', '\n    ')

    def printme(self):
        print(str(self))

    def printme2(self,
                 type_bit=True,
示例#3
0
from __future__ import division, print_function
import __common__
(print, print_, print_on, print_off,
 rrr, profile) = __common__.init(__name__, '[Printable]')
# Standard
import re
import copy
# Scientific
import numpy as np

MAX_VALSTR = -1
#100000


class AbstractPrintable(object):
    'A base class that prints its attributes instead of the memory address'

    def __init__(self, child_print_exclude=[]):
        self._printable_exclude = ['_printable_exclude'] + child_print_exclude

    def __str__(self):
        head = printableType(self)
        body = self.get_printable(type_bit=True)
        body = re.sub('\n *\n *\n', '\n\n', body)
        return head + ('\n' + body).replace('\n', '\n    ')

    def printme(self):
        print(str(self))

    def printme3(self):
        print(self.get_printable())
示例#4
0
'''
This module tries to ensure that the system paths are correctly setup for
hotspotter to run.
'''
from __future__ import print_function, division
import __common__
(print, print_, print_on, print_off,
 rrr, profile, printDBG) = __common__.init(__name__, '[cplat]', DEBUG=False)
import sys
from os.path import join, exists, normpath
import os
import subprocess

# Macports python directories
ports_pyframework = '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/'
ports_site_packages = join(ports_pyframework, 'lib/python2.7/site-packages/')


def ensure_pythonpath():
    if sys.platform == 'darwin':
        if exists(ports_pyframework) and not ports_pyframework in sys.path:
            sys.path.append(ports_site_packages)


def _cmd(*args, **kwargs):
    import shlex
    sys.stdout.flush()
    verbose = kwargs.get('verbose', True)
    detatch = kwargs.get('detatch', False)
    sudo = kwargs.get('sudo', False)
    if len(args) == 1 and isinstance(args[0], list):
示例#5
0
# http://docs.python.org/2/library/multiprocessing.html
from __future__ import print_function, division
import __common__
(print, print_, print_on, print_off, rrr, profile,
 printDBG) = __common__.init(__name__, '[parallel]', DEBUG=False)
# Python
from itertools import izip
from os.path import exists
import multiprocessing
import sys
# Hotspotter
import helpers
import pdb


def _calculate(func, args):
    printDBG('[parallel] * %s calculating...' %
             (multiprocessing.current_process().name, ))
    result = func(*args)
    #arg_names = func.func_code.co_varnames[:func.func_code.co_argcount]
    #arg_list  = [n+'='+str(v) for n,v in izip(arg_names, args)]
    #arg_str = '\n    *** '+str('\n    *** '.join(arg_list))
    printDBG('[parallel]  * %s finished:\n    ** %s' %
             (multiprocessing.current_process().name, func.__name__))
    return result


def _worker(input, output):
    printDBG('[parallel] START WORKER input=%r output=%r' % (input, output))
    for func, args in iter(input.get, 'STOP'):
        printDBG('[parallel] worker will calculate %r' % (func))
示例#6
0
from __future__ import division, print_function
import __common__
(print, print_, print_on, print_off, rrr,
 profile) = __common__.init(__name__, '[io]')
# Python
import os
import fnmatch
import pickle
import cPickle
from os.path import normpath, exists, realpath, join, expanduser, dirname
import datetime
import time
# Science
import numpy as np
import cv2
from PIL import Image
from PIL.ExifTags import TAGS
# Hotspotter
import helpers
#import skimage
#import shelve
#import datetime
#import timeit

VERBOSE_IO = 0  # 2


# --- Saving ---
def save_npy(fpath, data):
    with open(fpath, 'wb') as file:
        np.save(file, data)
示例#7
0
from __future__ import division, print_function
import __common__
(print, print_, print_on, print_off,
 rrr, profile) = __common__.init(__name__, '[io]')
# Python
import os
import fnmatch
import pickle
import cPickle
from os.path import normpath, exists, realpath, join, expanduser, dirname
import datetime
import time
import sys
# Science
import numpy as np
import cv2
from PIL import Image
from PIL.ExifTags import TAGS
# Hotspotter
import helpers

VERBOSE_IO = 0  # 2

ENABLE_SMART_FNAME_HASHING = False

if sys.platform.startswith('win32'):
    ENABLE_SMART_FNAME_HASHING = True


# --- Saving ---
def save_npy(fpath, data):
示例#8
0
# http://docs.python.org/2/library/multiprocessing.html
from __future__ import print_function, division
import __common__
(print, print_, print_on, print_off,
 rrr, profile, printDBG) = __common__.init(__name__, '[parallel]', DEBUG=False)
# Python
from itertools import izip
from os.path import exists, dirname, split
import multiprocessing
import os
import sys
# Hotspotter
import helpers as util


@profile
def _calculate(func, args):
    printDBG('[parallel] * %s calculating...' % (multiprocessing.current_process().name,))
    result = func(*args)
    #arg_names = func.func_code.co_varnames[:func.func_code.co_argcount]
    #arg_list  = [n+'='+str(v) for n,v in izip(arg_names, args)]
    #arg_str = '\n    *** '+str('\n    *** '.join(arg_list))
    printDBG('[parallel]  * %s finished:\n    ** %s' %
            (multiprocessing.current_process().name,
             func.__name__))
    return result


@profile
def _worker(input, output):
    printDBG('[parallel] START WORKER input=%r output=%r' % (input, output))
示例#9
0
'''Parameters module: DEPRICATE THIS
    stores a bunch of global variables used by the other modules
    It also reads from sys.argv'''
from __future__ import division, print_function
import __common__
(print, print_, print_on, print_off,
 rrr, profile) = __common__.init(__name__, '[params]')
# Python
from os.path import exists, join
import fileio as io
import sys

'''
print(' * __name__ = %s' % __name__)
print(' * sys.argv = %r' % sys.argv)
print(' * sys.checkinterval   = %r' % sys.getcheckinterval())
print(' * sys.defaultencoding = %r' % sys.getdefaultencoding())
print(' * sys.filesystemencoding = %r' % sys.getfilesystemencoding())
print(' * sys.prefix = %r' % sys.prefix)
'''


#=====================================================
# DEV DATABASE GLOBALS
#=====================================================
#def find_workdir():
    #workdir_list = [
        #'D:/data/work',
        #'/media/Store/data/work', ]
    #for workdir in workdir_list:
        #if exists(workdir):
示例#10
0
from __future__ import division, print_function
import __common__
(print, print_, print_on, print_off,
 rrr, profile) = __common__.init(__name__, '[latex]')
# Python
import re
import helpers
import textwrap
# Science
import numpy as np


def render(text):
    import pylab as plt
    import matplotlib as mpl

    #text = (r'\begin{document}' + '\n' +
            #text + '\n' +
            #r'\end{document}')
    print(text)

    mpl.rc('text', usetex=True)
    mpl.rc('font', family='serif')
    plt.figure()
    plt.text(9, 3.4, text, size=12)
    plt.show()


def latex_multicolumn(data, ncol=2):
    return r'\multicolumn{%d}{|c|}{%s}' % (ncol, data)
示例#11
0
from __future__ import division, print_function
import __common__
(print, print_, print_on, print_off,
 rrr, profile) = __common__.init(__name__, '[tools]')
# Python
import pylru  # because we dont have functools.lru_cache
import sys
import types
# Science
import numpy as np

# Very odd that I have to put in dtypes in two different ways.
VALID_INT_TYPES = (types.IntType,
                   types.LongType,
                   np.typeDict['int64'],
                   np.typeDict['int32'],
                   np.typeDict['uint8'],
                   np.dtype('int32'),
                   np.dtype('uint8'),
                   np.dtype('int64'),)

VALID_FLOAT_TYPES = (types.FloatType,
                     np.typeDict['float64'],
                     np.typeDict['float32'],
                     np.typeDict['float16'],
                     np.dtype('float64'),
                     np.dtype('float32'),
                     np.dtype('float16'),)

DEBUG = False
示例#12
0
'''Parameters module: DEPRICATE THIS
    stores a bunch of global variables used by the other modules
    It also reads from sys.argv'''
from __future__ import division, print_function
import __common__
(print, print_, print_on, print_off,
 rrr, profile) = __common__.init(__name__, '[params]')
# Python
import sys
import helpers
from os.path import exists, expanduser, join


'''
print(' * __name__ = %s' % __name__)
print(' * sys.argv = %r' % sys.argv)
print(' * sys.checkinterval   = %r' % sys.getcheckinterval())
print(' * sys.defaultencoding = %r' % sys.getdefaultencoding())
print(' * sys.filesystemencoding = %r' % sys.getfilesystemencoding())
print(' * sys.prefix = %r' % sys.prefix)
'''


#=====================================================
# DEV DATABASE GLOBALS
#=====================================================
def find_workdir():
    workdir_list = [
        'D:/data/work',
        '/media/Store/data/work', ]
    for workdir in workdir_list: