Skip to content

ENH: an example of a sandbox feature #3274

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

Closed
wants to merge 1 commit 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,56 @@ def use_inf_as_null_cb(key):
with cf.config_prefix('mode'):
cf.register_option('use_inf_as_null', False, use_inf_as_null_doc,
cb=use_inf_as_null_cb)


sb_xp_foo_doc = """
: boolean
Enables a snazzy, but not yet stable feature that could use
some feedback before going into core.
"""

def sandbox(gh_issue_num,msg=None):
def inner(cb):
def f(key):

s = """
This is an experimental feature being considered for inclusion in pandas core.
We'd appreciate your feedback on it in the Github issue page:

http://github.com/pydata/pandas/issues/%d

If you find this useful, lacking in major functionality or buggy please
take a moment to let us know, so we can make pandas (even) better.

Thank you,

The Pandas dev team

""" % gh_issue_num

if msg:
s += "P.S.\n\n" + msg

# don't print( the msessage on turn off
val = cf.get_option(key)
if val:
print(s)

return cb(key)

return f
return inner

@sandbox(3274,msg= "love the hair.")
def xp_foo_cb(key):
import pandas
val = cf.get_option(key)
if val:
from pandas.sandbox.xp import foo
pandas.DataFrame.foo = foo
else:
del pandas.DataFrame.foo

with cf.config_prefix('sandbox'):
cf.register_option('experimental_feature', False, sb_xp_foo_doc,
validator=is_bool, cb=xp_foo_cb)
4 changes: 4 additions & 0 deletions pandas/sandbox/xp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# monkey patched onto something, when the config options is enabled
def foo(self):
print "Hi, I'm an experimental new method. grrrr!" % type(self)