summaryrefslogtreecommitdiff
path: root/numpy/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "ENH: Adding __array_ufunc__ capability to MaskedArrays"Matti Picus2022-07-091-1/+1
|
* Merge pull request #16022 from greglucas/masked_ufuncMatti Picus2022-07-091-1/+1
|\ | | | | ENH: Adding __array_ufunc__ capability to MaskedArrays
| * ENH: Adding __array_ufunc__ capability to MaskedArrays.Greg Lucas2022-06-291-1/+1
| | | | | | | | | | | | This enables any ufunc numpy operations that are called on a MaskedArray to use the masked version of that function automatically without needing to resort to np.ma.func() calls.
* | Fix the interpolation formulae which led to absurd results. For quantile() ↵deego2022-07-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and percentile(). Fix the interpolation formulae in the docs which led to absurd results. For quantile() and percentile(). Example, for median of a = [1,2,10,11], you expect to obtain i+g=2.5 for method = linear (or weibull, or hazen, or median_unbiased or normal_unbiased). Instead, you obtain a /negative/ index. The correted formula is: i + g = q * (n - alpha - beta + 1 ) + alpha Notice among other things that n belongs in the numerator, not the denominator! As a check, the corrected formula does lead to the correct index 2.5 for each of the cases above. MYSTERY: Surely the original formula was the result of a small typo/thinko? Then, why does the correction look so completely different? RESOLUTION OF MYSTERY: Take our formula, massage it, and swap q with (i+g), and you end up with the original formula. In other words, the original author of the doc. simply confused their percentile with their index halfway through the creation of the doc. Then, they massaged it to isolate (i+g) on the left.
* | DOC: Clarify loadtxt input cols requirement (#21861)Pranab Das2022-07-021-2/+14
|/ | | | Also add an example to illustrate how usecols can be used to read a file with varying number of fields.
* BUG: Fix numpy.isin for timedelta dtype (#21860)Miles Cranmer2022-06-292-10/+41
| | | | | | | | | | | | | | | | | | | | | 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>
* Merge pull request #21863 from seberg/fpe-warning-simplificationCharles Harris2022-06-281-2/+1
|\ | | | | ENH,MAINT: Improve and simplify scalar floating point warnings
| * ENH,MAINT: Improve and simplify scalar floating point warningsSebastian Berg2022-06-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the scalar operations warnings read e.g.: overflow encountered in scalar multiply rather than: overflow encountered in float_scalars It also fixes one case where "assignment" rather than "cast" was used when I added the FPEs for casts. Otherwise, uses the helper that I intrudced for for the floating point casts in all places to simplify the code, the only "complicated" thing is that I try to give "scalar divide" rather than "scalar true_divide" as warnings, since "true_divide" should not really be something that end-users need be aware of.
* | BUG: Reject non integer array-likes with size 1 in delete (#21857)Sebastian Berg2022-06-282-14/+39
|/ | | | | | | | Non integer array-likes were not correctly rejected when a new fast-path was added to `np.delete` in gh-16895. This includes the _explicitly_ added `dtype=object` which should not be allowed since it is not allowed in normal indexing either. Closes gh-21840
* DOC: mention changes to `max_rows` behaviour in `np.loadtxt` (#21854)Pranab Das2022-06-271-2/+9
| | | | | * DOC: mention changes to `max_rows` behaviour * Clarify how line counting works in max_rows
* BUG: Use `keepdims` during normalization in `np.average` and `np.ma.average` ↵Srimukh Sripada2022-06-262-1/+13
| | | | | | | | | (#21851) The keepdims flag needs to be applied during the calculation of the sum of the weights in np.average and np.ma.average. Not passing it causes weights to broadcast incorrectly. Fixes #21850
* Merge pull request #21626 from seberg/weak-scalarsCharles Harris2022-06-261-4/+9
|\ | | | | API: Introduce optional (and partial) NEP 50 weak scalar logic
| * API: Add leading underscore to `no_nep50_warning` and `get/set_promotion_state`Sebastian Berg2022-06-151-1/+1
| |
| * TST: Adapt percentile test to changed promotionSebastian Berg2022-06-151-4/+9
| | | | | | | | | | | | Promotion in percentile will now more aggressively preserve the input dtype for floating point types (rather than upgrading the type to at least float64).
* | BUG: Fix in1d for empty integer array as input (#21842)Miles Cranmer2022-06-242-1/+26
| | | | | | | | | | | | | | | | | | | | | | * 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
* | Merge pull request #12065 from MilesCranmer/masterSebastian Berg2022-06-232-31/+244
|\ \ | | | | | | MAINT: Optimize np.isin and np.in1d for integer 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: Fix edgecase for bool containersMilesCranmer2022-06-221-2/+2
| | |
| * | DOC: Rephrase docstring of in1d/isinMilesCranmer2022-06-221-2/+2
| | |
| * | MAINT: Remove positionality of kind in isinMilesCranmer2022-06-221-2/+2
| | |
| * | MAINT: Minor suggestions from code reviewMiles Cranmer2022-06-221-4/+3
| | | | | | | | | Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
| * | DOC: Notes on `kind` to in1d/isin docstringMilesCranmer2022-06-201-10/+18
| | |
| * | DOC: `assume_unique` does not affect table methodMilesCranmer2022-06-201-4/+8
| | |
| * | DOC: Improve clarity of in1d docstringMilesCranmer2022-06-201-6/+6
| | |
| * | MAINT: change kind names for in1dMilesCranmer2022-06-182-49/+49
| | | | | | | | | | | | - Switch dictionary->table, mergesort->sort
| * | DOC: Fix list format for sphinxMiles Cranmer2022-06-181-9/+11
| | |
| * | DOC: Add missing indent in docstringMiles Cranmer2022-06-181-1/+1
| | |
| * | DOC: Fix formatting issues in docstringMilesCranmer2022-06-171-4/+2
| | |
| * | TST: validate in1d errorsMilesCranmer2022-06-171-0/+34
| | |
| * | MAINT: RuntimeError for unexpected integer overflowMilesCranmer2022-06-171-0/+7
| | |
| * | MAINT: Clean up integer overflow check in in1dMilesCranmer2022-06-171-11/+5
| | |
| * | MAINT: Clean up memory checking for in1dMilesCranmer2022-06-171-11/+9
| | |
| * | MAINT: Protect against integer overflow in in1dMilesCranmer2022-06-171-3/+6
| | |
| * | MAINT: kind now uses "mergesort" instead of "sort"MilesCranmer2022-06-172-27/+27
| | |
| * | TST: Use new "kind" argument over "method"MilesCranmer2022-06-171-20/+20
| | |
| * | MAINT: Switch parameter name to 'kind' over 'method'MilesCranmer2022-06-171-24/+28
| | |
| * | MAINT: Switch to old in1d for large memory usageMilesCranmer2022-06-171-13/+18
| | |
| * | MAINT: Fix misplaced default in in1d testMilesCranmer2022-06-101-2/+2
| | |
| * | MAINT: Add back in1d tests of old methodMilesCranmer2022-06-101-17/+17
| | |
| * | DOC: Describe memory considerations in in1d/isinMilesCranmer2022-06-101-10/+22
| | |
| * | DOC: Clean up isin docstringMilesCranmer2022-06-101-3/+3
| | |
| * | MAINT: bool instead of np.bool_ dtypeMilesCranmer2022-06-102-7/+7
| | |
| * | DOC: Improve docstring explanationMilesCranmer2022-06-101-2/+2
| | |
| * | MAINT: Formatting changes for in1dMiles Cranmer2022-06-101-2/+2
| | | | | | | | | Co-authored-by: Hameer Abbasi <2190658+hameerabbasi@users.noreply.github.com>
| * | MAINT: Fix error messageMilesCranmer2022-06-101-1/+2
| | |
| * | MAINT: Fix use of dispatcher for isinMilesCranmer2022-06-101-2/+2
| | |
| * | DOC: Describe default in docstringMilesCranmer2022-06-101-2/+2
| | |
| * | MAINT: Fix linting error in testMilesCranmer2022-06-101-1/+2
| | |
| * | DOC: Specify constraints of method in docstringMilesCranmer2022-06-101-2/+4
| | |