예제 #1
0
class FromTimestampCallable(object):
    def __call__(self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.array(
            list(map(str, map(datetime.datetime.fromtimestamp, args))))

    def __repr__(self) -> str:
        return 'map(str, map(from-timestamp(@{0}))'


###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser({
        'function': FromTimestampCallable(),
        'result': '@'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args(parser=parser)

    try:
        do.loop(args.function,
                args.parameters,
예제 #2
0
파일: diff.py 프로젝트: hsk81/quotestream
class DiffCallable (object):

    def __call__ (self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.diff (numpy.array (args).flatten ())

    def __repr__ (self) -> str:
        return 'diff (@{0})'

###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser ({
        'function': DiffCallable (), 'result': 'diff'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args (parser=parser)

    try: do.loop (args.function, args.parameters, args.stack_size,
        args.default, args.result, verbose=args.verbose)
예제 #3
0

class ProdCallable(object):
    def __call__(self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.prod(args)

    def __repr__(self) -> str:
        return 'prod(@{0})'


###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser({'function': ProdCallable(), 'result': 'prod'})

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args(parser=parser)

    try:
        do.loop(args.function,
                args.parameters,
                args.stack_size,
예제 #4
0
파일: inv.py 프로젝트: dudaka/quotestream

class LogCallable(object):
    def __call__(self, *args: [numpy.array], last=None) -> numpy.array:
        return 1.0 / numpy.array(args)

    def __repr__(self) -> str:
        return 'log (@{0})'


###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser({'function': LogCallable(), 'result': 'inv'})

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args(parser=parser)

    try:
        do.loop(args.function,
                args.parameters,
                args.stack_size,
예제 #5
0
파일: now.py 프로젝트: hsk81/quotestream
class NowCallable(object):
    def __call__(self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.array([time.time()])

    def __repr__(self) -> str:
        return '[time()]'


###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser({
        'function': NowCallable(),
        'parameters': [['timestamp']],  ## required dummy!
        'result': 'now'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args(parser=parser)

    try:
        do.loop(args.function,
예제 #6
0
파일: exp.py 프로젝트: hsk81/quotestream
class ExpCallable (object):

    def __call__ (self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.exp (args)

    def __repr__ (self) -> str:
        return 'exp (@{0})'

###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser ({
        'function': ExpCallable (), 'result': 'exp'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args (parser=parser)

    try: do.loop (args.function, args.parameters, args.stack_size,
        args.default, args.result, verbose=args.verbose)
예제 #7
0
파일: sqrt.py 프로젝트: hsk81/quotestream
class SqrtCallable (object):

    def __call__ (self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.sqrt (args)

    def __repr__ (self) -> str:
        return 'sqrt (@{0})'

###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser ({
        'function': SqrtCallable (), 'result': 'sqrt'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args (parser=parser)

    try: do.loop (args.function, args.parameters, args.stack_size,
        args.default, args.result, verbose=args.verbose)
예제 #8
0

class SqrtCallable(object):
    def __call__(self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.sqrt(args)

    def __repr__(self) -> str:
        return 'sqrt (@{0})'


###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser({'function': SqrtCallable(), 'result': 'sqrt'})

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args(parser=parser)

    try:
        do.loop(args.function,
                args.parameters,
                args.stack_size,
예제 #9
0
파일: exp.py 프로젝트: hsk81/quotestream

class ExpCallable(object):
    def __call__(self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.exp(args)

    def __repr__(self) -> str:
        return 'exp(@{0})'


###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser({'function': ExpCallable(), 'result': 'exp'})

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args(parser=parser)

    try:
        do.loop(args.function,
                args.parameters,
                args.stack_size,
예제 #10
0
        return result

    def __repr__(self):
        return 'div (*@{0})'


###############################################################################
###############################################################################

if __name__ == "__main__":
    div = DivCallable(default=[1.0])

    parser = do.get_args_parser({
        'function': div,
        'default': div.default,
        'result': 'div'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args(parser=parser)
    div.default = args.default

    try:
예제 #11
0
파일: div.py 프로젝트: hsk81/quotestream
            result = numpy.array (eval (self.default)
                if type (self.default) is str else self.default)

        return result

    def __repr__ (self):
        return 'div (*@{0})'

###############################################################################
###############################################################################

if __name__ == "__main__":
    div = DivCallable (default=[1.0])

    parser = do.get_args_parser ({
        'function': div, 'default': div.default, 'result': 'div'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args (parser=parser)
    div.default = args.default

    try: do.loop (args.function, args.parameters, args.stack_size,
        args.default, args.result, verbose=args.verbose)
예제 #12
0
파일: prod.py 프로젝트: redame/quotestream

class ProdCallable(object):
    def __call__(self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.prod(args)

    def __repr__(self) -> str:
        return "prod (@{0})"


###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser({"function": ProdCallable(), "result": "prod"})

    parser.description = """
        """

    parser.epilog = """
        """

    args = do.get_args(parser=parser)

    try:
        do.loop(args.function, args.parameters, args.stack_size, args.default, args.result, verbose=args.verbose)

    except KeyboardInterrupt:
        pass
예제 #13
0
파일: float.py 프로젝트: dudaka/quotestream
class FloatCallable (object):

    def __call__ (self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.array (args).astype (numpy.float)

    def __repr__ (self) -> str:
        return 'array (@{0}).astype (float)'

###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser ({
        'function': FloatCallable (), 'result': 'float'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args (parser=parser)

    if args.result == 'float':
        if len (args.parameters) > 0:
            args.result = args.parameters[0]
예제 #14
0

class DiffCallable(object):
    def __call__(self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.diff(numpy.array(args).flatten())

    def __repr__(self) -> str:
        return 'diff(@{0})'


###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser({'function': DiffCallable(), 'result': 'diff'})

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args(parser=parser)

    try:
        do.loop(args.function,
                args.parameters,
                args.stack_size,
예제 #15
0
파일: take.py 프로젝트: hsk81/quotestream
        self.jndex = jndex

    def __call__ (self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.array ([arg[self.jndex][self.index] for arg in args])

    def __repr__ (self) -> str:
        return '@{0}[index]'

###############################################################################
###############################################################################

if __name__ == "__main__":
    take = TakeCallable (index=0, jndex=0)

    parser = do.get_args_parser ({
        'function': take, 'result': '@[{index},{jndex}]'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    parser.add_argument ("-i", "--index", default=take.index, type=int,
        help="1st index to take (default: %(default)s)")
    parser.add_argument ("-j", "--jndex", default=take.index, type=int,
        help="2nd index to take (default: %(default)s)")
예제 #16
0
파일: inv.py 프로젝트: hsk81/quotestream
class LogCallable (object):

    def __call__ (self, *args: [numpy.array], last=None) -> numpy.array:
        return 1.0 / numpy.array (args)

    def __repr__ (self) -> str:
        return 'log (@{0})'

###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser ({
        'function': LogCallable (), 'result': 'inv'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args (parser=parser)

    try: do.loop (args.function, args.parameters, args.stack_size,
        args.default, args.result, verbose=args.verbose)
예제 #17
0
파일: take.py 프로젝트: hsk81/quotestream
    def __call__(self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.array([arg[self.jndex][self.index] for arg in args])

    def __repr__(self) -> str:
        return '@{0}[index]'


###############################################################################
###############################################################################

if __name__ == "__main__":
    take = TakeCallable(index=0, jndex=0)

    parser = do.get_args_parser({
        'function': take,
        'result': '@[{index},{jndex}]'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    parser.add_argument("-i",
                        "--index",
                        default=take.index,
                        type=int,
                        help="1st index to take(default: %(default)s)")
예제 #18
0
파일: now.py 프로젝트: hsk81/quotestream
class NowCallable (object):

    def __call__ (self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.array ([time.time ()])

    def __repr__ (self) -> str:
        return '[time ()]'

###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser ({
        'function': NowCallable (),
        'parameters': [['timestamp']], ## required dummy!
        'result': 'now'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args (parser=parser)

    try: do.loop (args.function, args.parameters, args.stack_size,
        args.default, args.result, verbose=args.verbose)
예제 #19
0
파일: sum.py 프로젝트: hsk81/quotestream
class SumCallable (object):

    def __call__ (self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.sum (numpy.array (args).flatten ())

    def __repr__ (self) -> str:
        return 'prod (@{0})'

###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser ({
        'function': SumCallable (), 'result': 'sum'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args (parser=parser)

    try: do.loop (args.function, args.parameters, args.stack_size,
        args.default, args.result, verbose=args.verbose)
예제 #20
0
class SumCallable(object):

    def __call__(self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.sum(numpy.array(args).flatten())

    def __repr__(self) -> str:
        return 'prod(@{0})'

###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser({
        'function': SumCallable(), 'result': 'sum'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args(parser=parser)

    try: do.loop(args.function, args.parameters, args.stack_size,
        args.default, args.result, verbose=args.verbose)
예제 #21
0
    def __call__ (self, *args: [numpy.array], last=None) -> numpy.array:
        return numpy.array (list (
            map (str, map (datetime.datetime.fromtimestamp, args))
        ))

    def __repr__ (self) -> str:
        return 'map (str, map (from-timestamp (@{0}))'

###############################################################################
###############################################################################

if __name__ == "__main__":

    parser = do.get_args_parser ({
        'function': FromTimestampCallable (), 'result': '@'
    })

    parser.description = \
        """
        """

    parser.epilog = \
        """
        """

    args = do.get_args (parser=parser)

    try: do.loop (args.function, args.parameters, args.stack_size,
        args.default, args.result, verbose=args.verbose)