summaryrefslogtreecommitdiff
path: root/numpy/ma
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge pull request #3448 from efiring/ma_compressCharles Harris2013-06-162-2/+21
|\ | | | | BUG: np.ma.compress treated inputs in wrong order; closes #2495
| * BUG: np.ma.compress treated inputs in wrong order; closes #2495Eric Firing2013-06-162-2/+21
| |
* | BUG: add __len__ method to ma.mvoid; closes #576Eric Firing2013-06-162-0/+7
| |
* | BUG: field assignment in masked array did not reset mask; closes #2403Eric Firing2013-06-152-3/+32
|/ | | | | | | | | The previous behavior when setting a field after indexing to select an element was suitable for the hard mask case, but not for the default soft mask. In addition, the _hardmask value was not being set at all in the mvoid instance. With this changeset, the _hardmask is passed in and __setitem__ takes it into account.
* BUG: ma: ma.average didn't handle complex arrays correctly (issue gh-2684)Warren Weckesser2013-06-152-9/+52
|
* MAINT: ma: clean up ma/test_extras.py: don't use 'import *'; PEP8 whitespaceWarren Weckesser2013-06-151-61/+67
|
* DOC: fix comments in min and ptp.John Benediktsson2013-06-061-2/+2
|
* TST: fix some function name conflictsJulian Taylor2013-06-052-2/+2
| | | | enables a few extra tests
* BUG: Correctly pass on ddof paramter on inside np.ma.corrcoefSebastian Berg2013-05-172-4/+11
| | | | | | While ddof has basically no effect on corrcoef, it exists, but it was not passed on correctly (instead only bias would be passed on). Fixes gh-3336
* MAINT: Apply 2to3 idioms fixer.Charles Harris2013-05-021-4/+4
| | | | | | | | | | | | | | | | | | | The idioms fixer makes the following replacements. 1) int <- bool 2) comparison or identity of types <- isinstance 3) a.sort() <- sorted(a) There were two problems that needed to be dealt with after the application of the fixer. First, the replacement of comparison or identity of types by isinstance was not always correct. The isinstance function returns true for subtypes whereas many of the places where the fixer made a substitution needed to check for exact type equality. Second, the sorted function was applied to arrays, but because it treats them as iterators and constructs a sorted list from the result, that is the wrong thing to do. Closes #3062.
* Merge pull request #3265 from jamestwebber/patch-2Charles Harris2013-04-272-2/+11
|\ | | | | Update masked array copy to preserve array order
| * Adding a test for #3265jamestwebber2013-04-201-0/+9
| | | | | | | | | | Test to ensure that MaskedArray.filled() doesn't change the order of the array. This test is a little messy because there are problems constructing an F-contiguous masked array in the first place. I had to explicitly pass in F-contiguous arrays for data and mask.
| * Update masked array copy to preserve array orderjamestwebber2013-04-201-2/+2
| | | | | | Using 'K' to try to match array order, fixes https://github.com/numpy/numpy/issues/3156
* | 2to3: Apply unicode fixer.Charles Harris2013-04-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The unicode fixer strips the u from u'hi' and converts the unicode type to str. The first won't work for Python 2 and instead we replace the u prefix with the sixu function borrowed from the six compatibility package. That function calls the unicode constructor with the 'unicode_escape' encoder so that the many tests using escaped unicode characters like u'\u0900' will be handled correctly. That makes the sixu function a bit different from the asunicode function currently in numpy.compat and also provides a target that can be converted back to the u prefix when support for Python 3.2 is dropped. Python 3.3 reintroduced the u prefix for compatibility. The unicode fixer also replaces 'unicode' with 'str' as 'unicode' is no longer a builtin in Python 3. For code compatibility, 'unicode' is defined either as 'str' or 'unicode' in numpy.compat so that checks like if isinstance(x, unicode): ... will work properly for all python versions. Closes #3089.
* | Merge pull request #3242 from charris/2to3-apply-types-fixerCharles Harris2013-04-212-5/+3
|\ \ | |/ |/| 2to3: Apply types fixer.
| * 2to3: Apply types fixer.Charles Harris2013-04-142-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Python 3 removes the builtin types from the types module. The types fixer replaces such references with the builtin types where possible and also takes care of some special cases: types.TypeNone <- type(None) types.NotImplementedType <- type(NotImplemented) types.EllipsisType <- type(Ellipsis) The only two tricky substitutions are types.StringType <- bytes types.LongType <- int These are fixed up to support both Python 3 and Python 2 code by importing the long and bytes types from numpy.compat. Closes #3240.
* | 2to3: Apply next fixer.Charles Harris2013-04-151-4/+4
|/ | | | | | | | | | | | | | The next builtin has been available since Python 2.6 and allows `it.next()` to be replaced by `next(it)`. In Python 3 the `next` method is gone entirely, replaced entirely by the `__next__` method. The next fixer changes all the `it.next()` calls to the new form and renames the `next` methods to `__next__`. In order to keep Numpy code backwards compatible with Python 2, a `next` method was readded to all the Numpy iterators after the fixer was run so they all contain both methods. The presence of the appropriate method could have been made version dependent, but that looked unduly complicated. Closes #3072.
* Merge pull request #3244 from charris/2to3-apply-zip-fixerCharles Harris2013-04-143-16/+16
|\ | | | | 2to3: Apply zip fixer.
| * 2to3: Apply zip fixer.Charles Harris2013-04-133-16/+16
| | | | | | | | | | | | | | | | | | | | In Python 3 zip returns an iterator instead of a list. Consequently, in places where an iterator won't do it must be enclosed in list(...). Lists instead of iterators are also used in array constructors as using iterators there usually results in an object array containing an iterator object. Closes #3094
* | 2to3: Apply basestring fixer.Charles Harris2013-04-132-6/+9
|/ | | | | | | | | | | The basestring class is not defined in Python 3 and the fixer replaces it with str. In order to have a common code base we define basestring in numpy/compat/py3k.py to be str when the Python version is >= 3, otherwise basestring and import it where needed. That works for most cases, but there are a few files where the version dependent define needs to be in the file. Closes #3042.
* 2to3: Apply the `numliterals` fixer and skip the `long` fixer.Charles Harris2013-04-131-1/+1
| | | | | | | | | | | | | | | | | | | The numliterals fixer replaces the old style octal number like '01' by '0o1' removes the 'L' suffix. Octal values were previously mistakenly specified in some dates, those uses have been corrected by removing the leading zeros. Simply Removing the 'L' suffix should not be a problem, but in some testing code it looks neccesary, so in those places the Python long constructor is used instead. The 'long' type is no longer defined in Python 3. Because we need to have it defined for Python 2 it is added to numpy/compat/np3k.py where it is defined as 'int' for Python 3 and 'long' for Python 2. The `long` fixer then needs to be skipped so that it doesn't undo the good work. Closes #3074, #3067.
* ENH: add `invert` parameter to numpy.in1d().Julien Phalip2013-04-082-3/+19
|
* 2to3: Apply `repr` fixer.Charles Harris2013-04-081-2/+2
| | | | | | | | | | | | This replaces python backtics with repr(...). The backtics were mostly used to generate strings for printing with a string format and it is tempting to replace `'%s' % repr(x)` with `'%r' % x`. That would work except where `x` happened to be a tuple or a dictionary but, because it would be significant work to guarantee that and because there are not many places where backtics are used, the safe path is to let the repr replacements stand. Closes #3083.
* Merge pull request #3205 from charris/2to3-apply-dict-fixerCharles Harris2013-04-071-1/+1
|\ | | | | 2to3: apply `dict` fixer.
| * 2to3: apply `dict` fixer.Charles Harris2013-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Python3 `dict.items()`, `dict.keys()`, and `dict.values()` are iterators. This causes problems when a list is needed so the 2to3 fixer explicitly constructs a list when is finds on of those functions. However, that is usually not necessary, so a lot of the work here has been cleaning up those places where the fix is not needed. The big exception to that is the `numpy/f2py/crackfortran.py` file. The code there makes extensive use of loops that modify the contents of the dictionary being looped through, which raises an error. That together with the obscurity of the code in that file made it safest to let the `dict` fixer do its worst. Closes #3050.
* | Merge pull request #3202 from charris/2to3-reduce-fixupsnjsmith2013-04-074-10/+7
|\ \ | |/ |/| MAINT: Cleanup some imports involving reduce.
| * MAINT: Cleanup some imports involving reduce.Charles Harris2013-04-064-10/+7
| | | | | | | | | | | | | | | | | | | | Because reduce has been available in functools since Python 2.6 we can get rid of the version checks we currently have before we import it. Also removes some reduce related skips in tools/py3tool.py. We were already skipping the reduce fixer so this has no effect other than cleaning up the code.
* | 2to3: Apply `print` fixer.Charles Harris2013-04-0615-40/+40
|/ | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* Merge pull request #3191 from charris/2to3-apply-imports-fixerCharles Harris2013-04-063-55/+42
|\ | | | | 2to3: Apply `imports` fixer.
| * 2to3: Apply `imports` fixer.Charles Harris2013-04-023-55/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `imports` fixer deals with the standard packages that have been renamed, removed, or methods that have moved. cPickle -- removed, use pickle commands -- removed, getoutput, getstatusoutput moved to subprocess urlparse -- removed, urlparse moved to urllib.parse cStringIO -- removed, use StringIO or io.StringIO copy_reg -- renamed copyreg _winreg -- renamed winreg ConfigParser -- renamed configparser __builtin__ -- renamed builtins In the case of `cPickle`, it is imported as `pickle` when python < 3 and performance may be a consideration, but otherwise plain old `pickle` is used. Dealing with `StringIO` is a bit tricky. There is an `io.StringIO` function in the `io` module, available since Python 2.6, but it expects unicode whereas `StringIO.StringIO` expects ascii. The Python 3 equivalent is then `io.BytesIO`. What I have done here is used BytesIO for anything that is emulating a file for testing purposes. That is more explicit than using a redefined StringIO as was done before we dropped support for Python 2.4 and 2.5. Closes #3180.
* | Merge pull request #460 from endolith/regex_formattingCharles Harris2013-04-032-6/+3
|\ \ | |/ |/| DOC: Formatting fixes using regex
| * DOC: regex-assisted fixes of definition list formattingendolith2013-03-192-3/+3
| |
| * DOC: Used regex to find colons missing spaces which render wrong online, ↵endolith2013-03-191-3/+0
| | | | | | | | also other spacing or formatting mistakes
* | 2to3: Use absolute imports.Charles Harris2013-03-2814-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new import `absolute_import` is added the `from __future__ import` statement and The 2to3 `import` fixer is run to make the imports compatible. There are several things that need to be dealt with to make this work. 1) Files meant to be run as scripts run in a different environment than files imported as part of a package, and so changes to those files need to be skipped. The affected script files are: * all setup.py files * numpy/core/code_generators/generate_umath.py * numpy/core/code_generators/generate_numpy_api.py * numpy/core/code_generators/generate_ufunc_api.py 2) Some imported modules are not available as they are created during the build process and consequently 2to3 is unable to handle them correctly. Files that import those modules need a bit of extra work. The affected files are: * core/__init__.py, * core/numeric.py, * core/_internal.py, * core/arrayprint.py, * core/fromnumeric.py, * numpy/__init__.py, * lib/npyio.py, * lib/function_base.py, * fft/fftpack.py, * random/__init__.py Closes #3172
* | 2to3: Replace xrange by range and use list(range(...)) where neededCharles Harris2013-03-273-13/+13
|/ | | | | | | | | | | | | | | In python3 range is an iterator and `xrange` has been removed. This has two consequence for code: 1) Where a list is needed `list(range(...))` must be used. 2) `xrange` must be replaced by `range` Both of these changes also work in python2 and this patch makes both. There are three places fixed that do not need it, but I left them in so that the result would be `xrange` clean. Closes #3092
* 2to3: Put `from __future__ import division in every python file.Charles Harris2013-03-0115-1/+36
| | | | | | | | This should be harmless, as we already are division clean. However, placement of this import takes some care. In the future a script can be used to append new features without worry, at least until such time as it exceeds a single line. Having that ability will make it easier to deal with absolute imports and printing updates.
* 2to3: Apply `raise` fixes. Closes #3077.Charles Harris2013-03-012-3/+3
| | | | | | | | | | Replaces the raise Exception, msg: form with raise Exception(msg):
* Merge pull request #2967 from sbyrnes321/masterCharles Harris2013-02-281-0/+9
|\ | | | | DOC -- add another paragraph note to ndarray.view docs
| * DOC -- add another paragraph note to ndarray.view docs (cont'd)Steve2013-02-051-6/+9
| | | | | | | | | | More detail: Views are only sensitive to under-the-hood storage when the dtype storage size has changed.
| * DOC -- add another paragraph note to ndarray.view docsSteve2013-02-041-0/+6
| | | | | | | | | | | | | | Since most numpy operations are not sensitive to underlying data structure (C-ordered arrays vs fortran-ordered arrays, versus slices or transposes of arrays, etc.), but structured-array views ARE sensitive to that, it is worth saying it explicitly in the documentation.
* | 2to3: Use modern exception syntax.Charles Harris2013-02-261-1/+1
|/ | | | Example: except ValueError,msg: -> except ValueError as msg:
* DEP: Remove scons related files and code.Charles Harris2013-01-131-18/+0
| | | | | | | | | This removes files and code supporting scons builds. After this change numpy will only support builds using distutils or bento. The removal of scons has been discussed on the list several times and a decision has been made that scons support is no longer needed. This was originally discussed for numpy 1.7 and because the distutils and bento methods are still available we are skipping the usual deprecation period.
* Merge pull request #2747 from mdboom/fix-masked-recarrays-with-objectsnjsmith2012-12-082-2/+13
|\ | | | | cannot access masked array rows with np.object dtype (Fixes #2432)
| * Add a testMichael Droettboom2012-12-031-0/+12
| |
| * Fixes #2432. Rather than creating a new data array and assigning to it ↵Michael Droettboom2012-11-151-2/+1
| | | | | | | | (which doesn't work when it is a recarray containing object fields), just create a copy with the np.array constructor.
* | Merge pull request #2745 from certik/fix_warningsOndřej Čertík2012-12-031-2/+14
|\ \ | | | | | | TST: Catch possible warnings
| * | TST: Catch possible warningsOndřej Čertík2012-11-141-2/+14
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the test sometimes fails with the following error: ====================================================================== ERROR: Test a special case for var ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/virtualenv/python3.2/lib/python3.2/site-packages/numpy/ma/tests/test_core.py", line 2731, in test_varstd_specialcases _ = method(out=mout) File "/home/travis/virtualenv/python3.2/lib/python3.2/site-packages/numpy/ma/core.py", line 4778, in std np.power(out, 0.5, out=out, casting='unsafe') RuntimeWarning: invalid value encountered in power ---------------------------------------------------------------------- Now we catch it, as recommended by the thread: http://old.nabble.com/Should-abs(-nan-)-be-supported--td34389839.html
* | Merge pull request #2703 from astrofrog/fix-masked-fill-viewRalf Gommers2012-11-272-2/+88
|\ \ | | | | | | Don't reset the fill_value of a MaskedArray when calling view() with no dtype
| * | Minor fix to fill_view testThomas Robitaille2012-11-221-1/+1
| | |
| * | Improvements to ndarray.view docstringThomas Robitaille2012-11-221-2/+3
| | |