Skip to content

BUG: Add check for array lengths in from_arrays method (GH13599) #13633

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

Conversation

sahildua2305
Copy link
Contributor

@sahildua2305 sahildua2305 commented Jul 12, 2016

@jreback
Copy link
Contributor

jreback commented Jul 12, 2016

tests!

@@ -632,6 +632,13 @@ def test_from_arrays_index_series_period(self):

tm.assert_index_equal(result, result2)

def test_from_arrays_different_lengths(self):
# GH13599
idx1 = [1, 2, 3]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a positive example (e.g. it doesn't raise)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I can assert explicitly that the ValueError isn't raised.

Should I simply add an example where array lengths are same and assert the response is the MultiIndex object with valid data?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you simply construct an expected MultiIndex and use .equals that it is equal to a result that uses .from_arrays. I am sure there are other examples to model from.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback is that test really required? The same input array length case is anyway getting checked in all other from_arrays related tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better yet make sure to check with a 0-len array (check for all 2 cases, idx1 or idx2 is 0-len)

@jreback
Copy link
Contributor

jreback commented Jul 13, 2016

pls add a whatsnew note for 0.19.0

@jreback jreback added Error Reporting Incorrect or improved errors from pandas MultiIndex labels Jul 13, 2016
yui-knk and others added 5 commits July 12, 2016 22:15
This commit suppresses these warnings

warning: comparison of constant -1 with expression\
of type 'PANDAS_DATETIMEUNIT' is always true\
[-Wtautological-constant-out-of-range-compare]

Author: yui-knk <[email protected]>

Closes pandas-dev#13607 from yui-knk/fix_c_warning and squashes the following commits:

e9eee1d [yui-knk] CLN: Fix compile time warnings
closes pandas-dev#12503

Author: Jeff Reback <[email protected]>

Closes pandas-dev#13147 from jreback/types and squashes the following commits:

244649a [Jeff Reback] CLN: reorg type inference & introspection
@codecov-io
Copy link

codecov-io commented Jul 13, 2016

Current coverage is 84.38%

Merging #13633 into master will increase coverage by 0.04%

@@             master     #13633   diff @@
==========================================
  Files           138        142     +4   
  Lines         51095      51226   +131   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43093      43227   +134   
+ Misses         8002       7999     -3   
  Partials          0          0          

Powered by Codecov. Last updated by 7c357d2...91691de

@@ -550,3 +550,5 @@ Bug Fixes
- Bug in ``groupby`` with ``as_index=False`` returns all NaN's when grouping on multiple columns including a categorical one (:issue:`13204`)

- Bug where ``pd.read_gbq()`` could throw ``ImportError: No module named discovery`` as a result of a naming conflict with another python package called apiclient (:issue:`13454`)

-Bug in ``MultiIndex.from_arrays`` doesn't check for arrays lengths (:issue:`13599`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't -> did not

array lengths -> input array lengths

yui-knk and others added 10 commits July 14, 2016 06:47
Author: yui-knk <[email protected]>

Closes pandas-dev#13643 from yui-knk/warning2 and squashes the following commits:

ee3a4fb [yui-knk] CLN: Fix compile time warnings
* CLN: fix params list

* Fix issue in asv.conf.json for win32+other environment

Fix mistaken exclusion of virtualenv or existing:same on win32 in the config.

Credits: @pv

* CLN: remove DataMatrix

* ASV: fix exlusion of tables package for non-conda environments
follow-up for pandas-dev#13593

Author: sinhrks <[email protected]>

Closes pandas-dev#13610 from sinhrks/depr_timestamp_offset2 and squashes the following commits:

28f8d41 [sinhrks] TST: add tests for Timestamp.toordinal
 - [x] tests added / passed   - [x] passes ``git diff upstream/master
| flake8 --diff``    Rebased version of
pandas-dev#10229 which was [actually not](h
ttps://github.com/pandas-dev/pull/10229#issuecomment-131470116)
fixed by pandas-dev#10199.    Nothing
particular relevant, just wanted to delete this branch locally and
noticed it still applies: you'll judge what to do of it.

Author: Pietro Battiston <[email protected]>

Closes pandas-dev#13594 from toobaz/fix_checkunique and squashes the following commits:

a63bd12 [Pietro Battiston] CLN: Initialization coincides with mapping, hence with uniqueness check
closes pandas-dev#12759
closes pandas-dev#13582

Author: sinhrks <[email protected]>

Closes pandas-dev#13609 from sinhrks/period_nat and squashes the following commits:

9305c36 [sinhrks] COMPAT: Period(NaT) now returns pd.NaT
…nt64

closes pandas-dev#13646

Author: Jeff Reback <[email protected]>

Closes pandas-dev#13661 from jreback/foo and squashes the following commits:

e26f9bf [Jeff Reback] BUG: construction of Series with integers on windows not defaulting to int64
Deprecated back in `0.15.0` and therefore long overdue.  Closes pandas-dev#8376.

Author: gfyoung <[email protected]>

Closes pandas-dev#13612 from gfyoung/categorical-levels-remove and squashes the following commits:

f1254df [gfyoung] MAINT: Relocated backwards compat categorical pickle tests
f3321cb [gfyoung] CLN: Removed levels attribute from Categorical
sinhrks and others added 26 commits July 18, 2016 21:04
Author: sinhrks <[email protected]>

Closes pandas-dev#13677 from sinhrks/append_series and squashes the following commits:

4bc7b54 [sinhrks] ENH: Series.append now has ignore_index kw
closes pandas-dev#13598

Author: wcwagner <[email protected]>

Closes pandas-dev#13690 from wcwagner/bug/13598 and squashes the following commits:

9669f3f [wcwagner] BUG: "Replaced isinstance with is_integer, and changed test_pad_width to use getattr"
40a3188 [wcwagner] BUG: "Switched to single test method asserting functions that use pad raise correctly."
06795db [wcwagner] BUG: "Added tests for width parameter on center, ljust, rjust, zfill."
468df3a [wcwagner] BUG: Add  type check for width parameter in str.pad method GH13598
closes pandas-dev#13603

Author: yui-knk <[email protected]>

Closes pandas-dev#13687 from yui-knk/fix_13603 and squashes the following commits:

0960395 [yui-knk] BUG: Cast a key to NaT before get loc from Index
…st entry

closes pandas-dev#13695

Author: Jeff Reback <[email protected]>

Closes pandas-dev#13698 from jreback/merge_asof and squashes the following commits:

c46dcfa [Jeff Reback] BUG: merge_asof not handling allow_exact_matches and tolerance on first entry
xref pandas-dev#9615

Author: gfyoung <[email protected]>

Closes pandas-dev#13670 from gfyoung/sandbox-removal and squashes the following commits:

2a014aa [gfyoung] CLN: removed pandas.sandbox
Follow-up of pandas-dev#10951.
Remove legacy offsets deprecated in 0.17.0.

Author: sinhrks <[email protected]>

Closes pandas-dev#13590 from sinhrks/depr_legacy_offset and squashes the following commits:

2593b1f [sinhrks] DEPR: Remove legacy offsets
xref pandas-dev#9611

Author: gfyoung <[email protected]>

Closes pandas-dev#13671 from gfyoung/cat-set-order-removal and squashes the following commits:

58938e7 [gfyoung] CLN: removed setter method of categorical's ordered attribute
fixes some issues from pandas-dev#13432
closes pandas-dev#12044
closes pandas-dev#12814

Author: Piotr Jucha <[email protected]>

Closes pandas-dev#13514 from pijucha/setop13432 and squashes the following commits:

3a96089 [Piotr Jucha] BUG/PERF: Sort mixed-int in Py3, fix Index.difference
closes pandas-dev#13536
closes pandas-dev#13535

Author: Kevin Sheppard <[email protected]>

Closes pandas-dev#13631 from bashtage/stata-data-labels and squashes the following commits:

1e1e1bf [Kevin Sheppard] ENH: Add support for writing variable labels
Author: sinhrks <[email protected]>

Closes pandas-dev#13664 from sinhrks/period_infer2 and squashes the following commits:

b208a9e [sinhrks] API: Index doesn't results in PeriodIndex if Period contains NaT
closes pandas-dev#11169
closes pandas-dev#11287

Author: sinhrks <[email protected]>

Closes pandas-dev#13692 from sinhrks/dti_perf and squashes the following commits:

8774772 [sinhrks] PERF: improve DTI string parse
closes pandas-dev#13618
closes pandas-dev#13520

Author: Chris <[email protected]>

Closes pandas-dev#13675 from chris-b1/resample-warning and squashes the following commits:

2185c1f [Chris] whatsnew note
c58c70c [Chris] DOC: resample warnings
xref pandas-dev#13327
closes pandas-dev#936

Author: Jeff Reback <[email protected]>

Closes pandas-dev#13513 from jreback/rolling and squashes the following commits:

d8f3d73 [Jeff Reback] ENH: add time-window capability to .rolling
closes pandas-dev#736

Author: sinhrks <[email protected]>

Closes pandas-dev#13706 from sinhrks/pivot_annual and squashes the following commits:

d097bab [sinhrks] DOC/DEPR: pivot_annual
closes pandas-dev#12817

Author: sinhrks <[email protected]>

Closes pandas-dev#13705 from sinhrks/period_hash and squashes the following commits:

e1fb7f4 [sinhrks] PERF: Improve Period hasing
Per discussion with @jreback <a href="https://github.com/pydata/pandas
pandas-dev/pull/13671#issuecomment-233508468">here</a>.

Author: gfyoung <[email protected]>

Closes pandas-dev#13702 from gfyoung/test-warnings-remove and squashes the following commits:

e7292d3 [gfyoung] MAINT: Removed some warnings in tests
Deprecated all the way back in `0.15.0` <a
href="https://github.com/pydata/pandas/pull/8227">here</a>.

Author: gfyoung <[email protected]>

Closes pandas-dev#13669 from gfyoung/remove-index-diff and squashes the following commits:

7dca659 [gfyoung] CLN: removed the 'diff' method for Index
@sahildua2305 sahildua2305 deleted the multi-from-arrays-fix branch July 20, 2016 21:58
@jorisvandenbossche
Copy link
Member

Superceded by #13728

@jorisvandenbossche jorisvandenbossche added this to the No action milestone Jul 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas MultiIndex
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MultiIndex.from_arrays() does not check lenghts