Skip to content
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

Minibatch: Add one-hot encoding option for int #259

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 27 additions & 5 deletions src/ports/postgres/modules/utilities/control.py_in
Expand Up @@ -10,21 +10,43 @@ m4_changequote(`<!', `!>')

@brief driver functions shared by modules
"""
import plpy

from distutils.util import strtobool
import plpy
from functools import wraps

from utilities import __mad_version
version_wrapper = __mad_version()
from utilities import unique_string
_unique_string = unique_string


STATE_IN_MEM = m4_ifdef(<!__HAWQ__!>, <!True!>, <!False!>)
HAS_FUNCTION_PROPERTIES = m4_ifdef(<!__HAS_FUNCTION_PROPERTIES__!>, <!True!>, <!False!>)
UDF_ON_SEGMENT_NOT_ALLOWED = m4_ifdef(<!__UDF_ON_SEGMENT_NOT_ALLOWED__!>, <!True!>, <!False!>)


# from https://coderwall.com/p/0lk6jg/python-decorators-vs-context-managers-have-your-cake-and-eat-it
class ContextDecorator(object):
""" Class to use a context manager also as a decorator

Inherit context manager classes from this class to use as a decorator
"""
def __init__(self, **kwargs):
self.__dict__.update(kwargs)

def __enter__(self):
# Note: Returning self means that in "with ... as x", x will be self
return self

def __exit__(self, typ, val, traceback):
pass

def __call__(self, f):
@wraps(f)
def wrapper(*args, **kw):
with self:
return f(*args, **kw)
return wrapper


class OptimizerControl(object):

"""
Expand Down Expand Up @@ -112,7 +134,7 @@ class HashaggControl(object):
format(('off', 'on')[self.hashagg_enabled]))


class MinWarning:
class MinWarning(ContextDecorator):

"""
@brief A wrapper for setting the level of logs going into client
Expand Down