summaryrefslogtreecommitdiff
path: root/numpy/core/getlimits.py
Commit message (Collapse)AuthorAgeFilesLines
* ENH: Improve performance of finfo and _commonType (#23088)Pieter Eendebak2023-02-151-5/+16
| | | | | | | | | | | | | The finfo contains a cache for dtypes, but the np.complex128 dtype does not end up in the cache. The reason is that the np.complex128 is converted to np.float64 which is in the cache. Performance improvement for finfo(np.complex128): Main: 2.07 µs ± 75 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) Pr: 324 ns ± 28.9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) Improve performance of finfo by making the cache check the first action in the __new__ Improve performance of _commonType by re-using the expression for a.dtype.type and eliminating variables The finfo and _commonType was part of the computatation time in lstsq when using scikit-rf. Since these methods are used in various other methods performance can improve there slightly as well.
* WHL: musllinux wheels [wheel build]Andrew Nelson2023-02-011-3/+14
|
* DEP: deprecate np.finfo(None) (#23011)Daiki Shintani2023-01-191-0/+9
| | | | | Deprecate np.finfo(None), it may be that we should more generally deprecate `np.dtype(None)` but this is a start and particularly weird maybe. Closes gh-14684
* Merge pull request #22619 from seberg/move-set_moduleMatti Picus2022-11-291-1/+1
|\ | | | | MAINT: Move set_module from numpy.core to numpy._utils
| * MAINT: Move set_module to numpy.core to use without C importSebastian Berg2022-11-241-1/+1
| |
* | DEP: Finalize MachAr and machar deprecationsSebastian Berg2022-11-221-20/+3
|/ | | | | | This removes the attributes on finfo and the "public" module. It also deprecates `np.core.MachAr`. We should be able to get away with just deleting it, but there seems little reason to not just deprecate it for now.
* DOC: Added missing dtype attribute to `iinfo` and `finfo` docstring (#22334)Matteo Raso2022-09-271-0/+14
| | | | | | | finfo() and iinfo() both have a dtype attribute, which was undocumented before this commit. [skip azp] [skip actions] Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com>
* DOC: Clarified how finfo works with complex numbers (#22260)Matteo Raso2022-09-141-1/+7
| | | | | | | | | | | | | | | | There was some confusion about how finfo works with complex numbers, leading to an issue being made requesting that numpy either adds a cinfo function or changes the documentation of finfo. The submitter of that issue also linked to an issue for a seperate repository, which also included conversation about the proposed change. (github.com/data-apis/array-api/issues/433) In both discussions, there was a general concensus that it would be better to change the documentation to explain how finfo works instead of creating a cinfo function. Since this is just a small documentation change, there's no need to run the normal checks. [skip ci]
* BUG: Fix discovered MachAr (still used within valgrind)Sebastian Berg2022-06-211-2/+3
| | | | | | | | | | This fixes the missing attributes. I tested the warning and fix on valgrind itself. These attributes were added in gh-18536 but the fallback path was not checked there. Replaces gh-21813, although something more like it may make sense if it allows us to just delete MachAr completely.
* DEP: Deprecate `finfo.machar`Bas van Beek2021-10-271-3/+19
|
* DEP: Deprecate the `np.core.machar` moduleBas van Beek2021-10-261-1/+1
|
* MAINT: remove unused importsAlessia Marcolini2021-10-081-1/+0
|
* ENH: Add smallest_normal and smallest_subnormal attributes to finfo (#18536)Stephannie Jimenez Gacha2021-07-191-48/+166
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ENH: Add smallest_normal and smallest_subnormal attributes to finfo class * ENH: Add smallest_normal and smallest_subnormal attributes to MachAr * BUG: Fix minor bug in the calc of smallest_subnormal attribute * ENH: Use nextafter to calculate smallest subnormal in finfo * ENH: Use nextafter for calculating all subnormal numbers * ENH: Add warning in case the subnormal number is zero and hardcode double double value * FIX: Fix docstring in new function * FIX: Add stacklevel parameter to warning * ENH: Move smallest_subnormal to a property and add a test * FIX: Only hardcode the subnormal value for double double * FIX: Fix subnormal warning test * FIX: Fix the hardcoded value for double double type * FIX: Fix failing test by supressing an overflow warning * ENH: Fix the value for smallest_normal and tiny in double double * BUG: Fix failing tests when tiny is NaN * BUG: Fix failing test when tiny is NaN * ENH: add review fixes * ENH: Raise TypeError for smallest_subnormal/tiny value in longdouble * FIX: Replace TypeError with warning * BUG: Fix tests * ENH: Add release note * ENH: Add review changes * BUG: Fix wrong value in smallest_subnormal Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> * BUG: Fix wrong value in subnormal number * ENH: Bind the smallest_normal warning to the finfo class * BUG: Revert warning supression in tests * ENH: Add review changes * BUG: Fix failing test * BUG: Fix test identation * BUG: Fix typo * Update numpy/core/tests/test_getlimits.py Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* MAINT: Avoid accessing uninitialized bytes getlimits (#16834)Yu Feng2020-07-131-4/+8
| | | | | | | | This very simple flip of ordering avoids accessing the last 6 uninitialized bytes of 80-bit floats. Since none of our known `long double` patterns share the 10-byte prefix, this change does not effect behavior. Accessing these bytes does not invoke any undefined behavior, but it does cause false positives in tools like `msan` and `valgrind`, which is reason enough to avoid doing so. `msan` does not always report this error, likely due to the caching of memory allocation.
* DOC: Calrify tiny/xmin in finfo and machar (gh-16253)Raphael Kruse2020-05-181-3/+14
| | | | | | | | | | | | | | | | | | | This commit adds a note to the documentation of finfo clarifying that the attribute `tiny` does not represent the smallest positive usable number. Instead it refers to the smallest positive number with there being no leading 0's in the mantisse (normalized floating point number). Alternatively, `tiny` represents the smallest positive floating point number with full precision. The smallest positive subnormal floating point number is typically orders of magnitudes smaller, but has reduced precision since leading 0's in the mantisse are used to allow smaller exponents than indicated by `minexp`. The commit also adds a brief clarification to the docstring of machar. Closes #16252 Co-authored-by: Anirudh Subramanian <anirudh2290@apache.org> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* DOC: Improve np.finfo docs (#15678)Ross Barnowski2020-03-011-6/+9
| | | | | | | | | | | | | | | | | * DOC: Improve docs for np.finfo. Replace inaccurate statements about eps and epsneg attrs with correct statements and examples. Added np.spacing and np.nextafter to See Also. Closes #6940. * Removed LaTeX math from finfo docstring. * MAINT: Add periods at end of some sentences. Co-authored-by: Charles Harris <charlesr.harris@gmail.com>
* MAINT: Implement keyword-only arguments as syntaxEric Wieser2020-01-061-6/+6
| | | | Now that 2.7 is gone, there is no need to pop manually from kwarg dictionaries.
* 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.
* MAINT: Convert property to @propertyAlex Watt2019-02-241-4/+2
|
* ENH: set correct __module__ for objects in numpy's public APIStephan Hoyer2018-11-131-0/+3
| | | | | | | | | | | | | Fixes GH-12271 Tests verify that everything in ``dir(numpy)`` either has ``__module__`` set to ``'numpy'``, or appears in an explicit whitelist of undocumented functions and exported bulitins. These should eventually be documented or removed. I also identified a handful of functions for which I had accidentally not setup dispatch for with ``__array_function__`` before, because they were listed under "ndarray methods" in ``_add_newdocs.py``. I guess that should be a lesson in trusting code comments :).
* MAINT: cleanup getlimit global varsAllan Haldane2018-10-091-137/+137
|
* MAINT: delay initialization of getlimits (circular imports)Allan Haldane2018-10-091-197/+184
| | | | | | | getlimits previously called numpy code before all of numpy was loaded, which often causes circular import issues. This delays getlimits init. Fixes #12063
* Provide information about what kind is actually not integer kindYaroslav Halchenko2018-10-051-1/+1
| | | | | | | | Otherwise it is hard to impossible to figure out what is the actual value which fails the test. See e.g. failing on 3.4 (only) tests of nibabel: https://ci.appveyor.com/project/nipy/nibabel/build/1.0.498/job/eechfm1kxroa0rju#L598
* RF: remove main clauseMatthew Brett2017-05-151-10/+0
| | | | Does not work, and shouldn't be there.
* RF: delay calls of array repr in getlimitsMatthew Brett2017-05-151-6/+26
| | | | | | | | Delay use of array repr until needed for string representations of the float info parameters. This is to allow getlimits to be imported early without pulling in too much of the repr machinery. See: https://github.com/numpy/numpy/pull/8983#discussion_r115838683
* BUG: match hard-coded finfo to calculated MachArMatthew Brett2017-02-091-24/+30
| | | | | | | Make sure that value shapes and dtypes are the same as the original calculated values from the MachAr class. Closes #8585
* ENH: hard-code finfo parameters for known types (#8504)Matthew Brett2017-02-031-25/+256
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ENH: hard-code finfo parameters for known types Hard-code the MachAr parameters for float64, float32, 80-bit extended precision, to save time, and provide skeleton for more difficult types such as the double double on PPC; see https://github.com/numpy/numpy/issues/2669 * ENH: add PPC long double finfo Add parameters for PPC long double, fixing long-standing bug for finfo on PPC. * BF: use Python floats for float64 finfo For some reason (garrgh) np.exp2 with float64 gives a different answer on Windows than it does on other platforms; use Python floating point calculations instead, which do appear to be consistent. * DOC: add release notes for finfo fixes Add release note describing fixes for PPC long double ``finfo``. * RF: try using byte string to identify floats From suggestion by Chuck, and https//perl5.git.perl.org/perl.git/blob/3118d7d684b56cbeb702af874f4326683c45f045:/Configure * TST: add tests for reasonable finfo parameters Check that finfo returns somewhat reasonable parameters for all floating point types. * RF: add warning for not-recognized float type Warn if we don't have a signature for the float type. * NF: add IEEE float128 type signature Still needs test on platform with IEEE float128, to check MachAr-like parameters are correct.
* ENH: Add bits attribute to np.finfo, closes #1886Jaime Fernandez2016-06-041-6/+11
| | | | | | | Add a bits attribute to np.finfo, document the existence of this attribute for both np.iinfo and np.finfo, plus some extra spacing around the __str__ labels to make the representation consistent for both classes.
* STY: PEP8 fixes for numpy/core/*.pyCharles Harris2015-07-051-23/+25
|
* DOC: Reconcile docstrings and function signatures where they disagreeRobert McGibbon2015-03-021-1/+1
| | | | | Fixed typos in docstrings were updated for functions where the parameter names in the docstring didn't match the function signature.
* STY: Giant comma spacing fixup.Charles Harris2013-08-181-14/+14
| | | | | | | Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long and will need to be broken at some point. OTOH, some lines were already too long and need to be broken at some point. Now seems as good a time as any to do this with open PRs at a minimum.
* 2to3: Apply the `numliterals` fixer and skip the `long` fixer.Charles Harris2013-04-131-3/+3
| | | | | | | | | | | | | | | | | | | 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.
* 2to3: Apply `print` fixer.Charles Harris2013-04-061-7/+7
| | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* 2to3: Use absolute imports.Charles Harris2013-03-281-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Put `from __future__ import division in every python file.Charles Harris2013-03-011-1/+3
| | | | | | | | 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.
* ENH: add useful repr's for finfo, iinfo.Brent Pedersen2011-08-181-0/+11
|
* STY: Fix up some remaining old-style exceptions.Charles Harris2011-04-051-1/+1
| | | | I think that is the end of it.
* STY: Update exception styles, trickier ones.Charles Harris2011-04-051-1/+1
|
* STY: Replace remaining old style classes with classes subclassing object.Charles Harris2011-04-051-1/+1
|
* DOC: fix doc build complaint about too-long tables.rgommers2011-03-021-5/+7
|
* DOC: merge wiki edits for numpy.core.rgommers2011-03-021-18/+20
|
* ENH: core: Add half/float16 finfo supportMark Wiebe2010-12-011-0/+4
|
* BUG: core: finfo.tiny, resolution, and epsneg should be scalars (#1538)Pauli Virtanen2010-07-171-1/+1
|
* Docstring update: corePauli Virtanen2009-10-021-6/+4
|
* Move finfo into core.David Cournapeau2009-09-161-0/+287