-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG/TST: reset setitem_copy on object enlargement #5584
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
Conversation
this fixes the warning in can you give a whirl. |
Yep that did it. |
@TomAugspurger pls give this updated one a whirl... can you post a script of what you are doing...I can add as tests... |
I'm just running the On master:
This PR:
The causing the warning was this one: def test_set_value_keeps_names(self):
# motivating example from #3742
lev1 = ['hans', 'hans', 'hans', 'grethe', 'grethe', 'grethe']
lev2 = ['1', '2', '3'] * 2
idx = pd.MultiIndex.from_arrays(
[lev1, lev2],
names=['Name', 'Number'])
df = pd.DataFrame(
np.random.randn(6, 4),
columns=['one', 'two', 'three', 'four'],
index=idx)
df = df.sortlevel()
self.assertEqual(df.index.names, ('Name', 'Number'))
df = df.set_value(('grethe', '4'), 'one', 99.34) # <<<< this line
self.assertEqual(df.index.names, ('Name', 'Number')) |
Why don't we default SettingWithCopy to error in the test suite? (and then |
@TomAugspurger ok...that was my test case as well @jtratner in theory you could do that after this PR. In Let me change it |
@jtratner I can set it in a couple of the likely test suits...any way to change it 'globally' though? (only for testing)? |
the right way to do this is to have a pandas unittest class then have all tests inherit from this, and have the setup in a sub always call this, but more work that what I am doing |
too hacky? I don't want to just import the test suite to actually trigger this so I think have to actually call it at the top of each file (because you could just call that file independently). We don't have a 'global' test suite setup ATM |
Hmm, that's true. |
Why not just define a class with a setUp method and have other modules |
@jtratner you could do that but then you have to make sure that an existing that would then allow say ignoring of |
Okay, however you want to do it is fine with me. Maybe there's a global
|
looks like you can do |
@jtratner alright...revised to baseclass all TestCases....whoosh! |
Okay I'll take a look tonight. |
@jtratner give this a look see pls |
TST: eliminate SettingWithCopyWarnings in tests (catch them) TST: tests for GH5597 BUG: don't set copy on equal indexes after an operation
…l.testing.TestCase
@jtratner ok with this? |
|
||
""" | ||
|
||
class TestNewOffsets(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this get deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was all commented out - afaik never used
@jreback this looks fine, though I realized we could have just defined a single So could have just done this: def setup_package():
pd.set_option('chained_assignment','raise')
#print("setting up: {0}".format(cls))
def teardown_package():
#print("tearing down up: {0}".format(cls))
pass and then in test from pandas.util.testing import setup_package, teardown_package so knowledge for the future. |
ok that's prob about the same amount of code I guess |
BUG/TST: reset setitem_copy on object enlargement
related #5581
closes #5597