summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_arraysetops.py
Commit message (Collapse)AuthorAgeFilesLines
* BUG: Fix integer overflow in in1d for mixed integer dtypes #22877 (#22878)Miles Cranmer2022-12-251-2/+37
| | | | | | | | | | | | | | | | | | | * TST: Mixed integer types for in1d * BUG: Fix mixed dtype overflows for in1d (#22877) * BUG: Type conversion for integer overflow check * MAINT: Fix linting issues in in1d * MAINT: ar1 overflow check only for non-empty array * MAINT: Expand bounds of overflow check * TST: Fix integer overflow in mixed boolean test * TST: Include test for overflow on mixed dtypes * MAINT: Less conservative overflow checks
* BUG: Fix numpy.isin for timedelta dtype (#21860)Miles Cranmer2022-06-291-0/+31
| | | | | | | | | | | | | | | | | | | | | This PR fixes the issue discussed on #12065 and #21843 where 'timedelta64' was noted to be a subtype of numpy.integer. This in principle should detect any cases where int(np.min(ar2)) fails. This PR also adds unittests for these. * TST: Create in1d test for timedelta input * MAINT: fix in1d for timedelta input * TST: in1d raise ValueError for timedelta input * MAINT: Clean up type checking for isin kind="table" * TST: Add test for mixed boolean/integer in1d * MAINT: Increase readability of in1d type checking * STY: Apply small code style tweaks This is probably really mainly my personal opinion... Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* BUG: Fix in1d for empty integer array as input (#21842)Miles Cranmer2022-06-241-1/+19
| | | | | | | | | | | * TST: Tests empty input to in1d of various types * MAINT: Skip table method on empty input array * MAINT: Check array size before call to min * MAINT: Return early for kind="table" and empty ar2 * TST: Test other dtypes of empty arrays
* TST: Skip empty arrays for kind="table"Miles Cranmer2022-06-221-5/+7
|
* TST: Reduce code re-use with pytest markMilesCranmer2022-06-221-142/+40
|
* MAINT: change kind names for in1dMilesCranmer2022-06-181-26/+26
| | | | - Switch dictionary->table, mergesort->sort
* TST: validate in1d errorsMilesCranmer2022-06-171-0/+34
|
* MAINT: kind now uses "mergesort" instead of "sort"MilesCranmer2022-06-171-18/+18
|
* TST: Use new "kind" argument over "method"MilesCranmer2022-06-171-20/+20
|
* MAINT: Fix misplaced default in in1d testMilesCranmer2022-06-101-2/+2
|
* MAINT: Add back in1d tests of old methodMilesCranmer2022-06-101-17/+17
|
* MAINT: bool instead of np.bool_ dtypeMilesCranmer2022-06-101-1/+1
|
* MAINT: Fix linting error in testMilesCranmer2022-06-101-1/+2
|
* MAINT: Update tests to use new `method` argumentMilesCranmer2022-06-101-19/+20
|
* MAINT: Fix linting errors in in1d testsMilesCranmer2022-06-091-8/+18
|
* TST: Extend np.in1d tests to old algorithmMilesCranmer2022-06-091-2/+42
| | | | | - Add flag ``_slow_integer`` to np.isin/np.in1d to force the use of the old isin/in1d algorithm for integers.
* TST: add tests for in1d/isinMilesCranmer2022-06-091-0/+99
| | | | | | - These tests hit the areas of the old algorithm which are now replaced for the majority of cases - Another test tests behaviour of boolean input to isin/in1d
* MAINT: Fixup `unique`s `equal_nan` kwarg to match `np.array_equal`Sebastian Berg2022-06-011-1/+1
| | | | | | | | The other similar arguments in the testing functions and `np.array_equal` use `equal_nan` and not `equal_nans` (with plural s). So it seems we should use that here as well for consistency. Does some very minor style fixes otherwise.
* TST: Added test for np.unique equal_nans kwargJason Thai2022-05-281-0/+8
|
* BUG: Do not raise deprecation warning for all nans in unique (#19301)Thomas J. Fan2021-06-291-0/+11
| | | | | This PR adjusts np.unique for the edge cases where all values are nan. Fixes gh-19300
* BUG: Fix unique handling of nan entries. (#18070)Filip Trojan2021-02-121-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * benchmark bench_lib.Unique added * extended test_unique_1d * modify _unique1d * extend test with return_index, return_inverse and return_counts parameters * documentation updated * Update numpy/lib/arraysetops.py Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com> * full coverage of nan types Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com> * added tests for the datetime like dtypes * nan as vector of length 1 * use aux[-1] as nan, ..versionchanged, release note * for complex arrays all NaN values are considered equivalent Co-authored-by: filip_trojan <Tarantula2018> Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com>
* numpy/lib/arraysetops.pyAngelGris2021-02-081-0/+33
|
* BUG: Fixes incorrect error message in numpy.ediff1d (#17457)stuartarchibald2020-10-051-7/+11
| | | | | | Fixes the error message reported by ediff1d in the case of an invalid to_begin and updates tests to assert validity. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* MAINT: lib: PEP-8 clean up in test_arraysetops.py.Warren Weckesser2020-03-151-38/+41
|
* BUG: lib: Handle axes with length 0 in np.unique.Warren Weckesser2020-03-151-0/+6
| | | | | | | Tweak a few lines so that arrays with an axis with length 0 don't break the np.unique code. Closes gh-15559.
* TST: lib: Add a unit test for np.unique applied to arrays with a length 0 axis.Huon Wilson2020-03-151-0/+35
| | | | | This code is from github user huonw, from this PR: https://github.com/numpy/numpy/pull/15565
* MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-051-3/+3
| | | | | | | Inheriting from object was necessary for Python 2 compatibility to use new-style classes. In Python 3, this is unnecessary as there are no old-style classes. Dropping the object is more idiomatic Python.
* MAINT: Remove unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-031-2/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* BUG: Make ``ediff1d`` kwarg casting consistentSebastian Berg2019-11-251-7/+12
| | | | | | | | | | | | | | This reverts commit c088383cb290ca064d456e89d79177a0e234cb8d and uses the same kind casting rule for the additional keyword arguments ``to_end`` and ``to_begin``. This results in slightly more leniant behaviour for integers (which can now have overflows that are hidden), but fixes an issue with the handling of NaN. Generally, this behaviour seems more conistent with what NumPy does elsewhere. The Overflow issue exists similar in many other places and should be solved by integer overflow warning machinery while the actual cast takes place. Closes gh-13103
* fix uniqueHuang, Guangtai2019-08-131-2/+5
|
* MAINT: Replace integers in places where booleans are expectedMSeifert042019-07-011-7/+7
|
* BUG: loosen kwargs requirements in ediff1dmattip2019-01-101-4/+4
|
* MAINT: Review F401,F841,F842 flake8 errors (unused variables and imports) ↵Roman Yurchak2018-12-061-1/+0
| | | | | | | | | | | | (#12448) * Review F401,F841,F842 flake8 errors (unused variables, imports) * Review comments * More tests in test_installed_npymath_ini * Review comments
* DOC, TST: test setdiff1d assume_uniqueTyler Reddy2018-10-161-0/+7
| | | | | | | | * add unit test for setdiff1d covering code path where assume_unique is True * remove setdiff1d docstring guarantee that returned value is sorted -- it is not
* BUG: add type cast check to ediff1dTyler Reddy2018-08-261-1/+66
|
* BUG: Fix regression in intersect1d.Charles Harris2018-08-171-7/+18
| | | | | | | | | The function was failing for non-ndarray objects that defined that defined __array__, in particular `xarray.DataArray`. Fix by calling asanyarray on the inputs, which was done implicitly before. Closes #11772.
* ENH: Modify intersect1d to return common indices (#10684)Christopher2018-05-251-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * added function commonpts1d * Update arraysetops.py * Update arraysetops.py * modified intersect1d to return common indices Proposed this idea in previous pull request (https://github.com/numpy/numpy/pull/10683) and made suggested changes for implementing this idea to have relevant common indices that correspond to the values in the intersection of the two arrays. * update intersect1d with suggested changes * implemented return_indices options for intersect1d I've tested out the above code and for the ~10 different test sets I've tried it's worked thus far. It's probably not the cleanest implementation but it works and is vectorized. * cleaned up structure for intersect1d * fixed copy-paste error, added second test, changed a conditional * Testing return_indices in intersect1d * formatting * created separate test function for intersect1d indices, added spaces after commas * fixed up example and some style * fixed style * style change * removed one example * removed extra space * added version number for return_indices * added 'return_indices' keyword for np.intersect1d * fixed formatting * updated return_indices entry * fixed some typos and style * added bit about first instance of a value being used * STY: Fix comment formats * DOC: missing space * DOC: correct parameter names in docstring * made suggested changes * fixed a mistake from previous update also added documentation for comm1, comm2 to match doc from np.unique * added in tests for 2d inputs * STY: Add missing spaces around commas * TST: Correct array to actually be unique * STY: Spaces at beginning of comments
* MAINT: move matrix tests in lib to matrixlib.Marten van Kerkwijk2018-04-291-2/+0
|
* MAINT: Remove all uses of run_module_suite.Charles Harris2018-04-061-7/+1
| | | | | That function is nose specific and has not worked since `__init__` files were added to the tests directories.
* BUG: Revert sort optimization in np.unique.Charles Harris2018-02-141-0/+11
| | | | | | | | The optimization was to sort integer subarrays by treating them as strings of unsigned bytes. That worked fine for finding the unique subarrays, but the sort order of the results could be unexpected. Closes #10495.
* MAINT: Use AxisError in swapaxesEric Wieser2018-02-031-2/+2
|
* STY: Break some long lines.Charles Harris2018-01-181-1/+2
| | | [ci skip]
* adding a reference to the related issueAnas Khan2018-01-101-0/+1
|
* adding new tests for union1dAnas Khan2018-01-091-0/+6
|
* ENH: Make `np.in1d()` work for unorderable object arrays (#9999)Jörg Döpfert2017-11-181-0/+31
|
* TST: Remove unittest dependencies in numpy/lib/tests.Charles Harris2017-07-241-8/+8
|
* BUG: set default type for empty index array to `numpy.intp` (#9142)Konrad Kapp2017-05-201-0/+10
| | | | Fixes #9137
* ENH: Add isin, genereralizing in1d to ND arrays (#8423)B R S Recht2017-05-051-1/+41
| | | | | | This fixes gh-8331 Also update the docs for arraysetops to remove the outdated "1D" from the description, which was already incorrect for np.unique.
* BUG: Make MaskedArray.argsort and MaskedArray.sort consistentEric Wieser2017-03-071-0/+12
| | | | | | | Previously, these had different rules for unmasking values, and even different arguments to decide how to do so. Fixes #8664
* Added axis argument to numpy.uniquemartinosorb2016-11-131-105/+186
|