Skip to content

Commit

Permalink
Merge branch 'master' into config-load-dll
Browse files Browse the repository at this point in the history
  • Loading branch information
xoviat authored Dec 31, 2017
2 parents 887bb66 + 5f28111 commit 56b3b66
Show file tree
Hide file tree
Showing 60 changed files with 5,869 additions and 1,851 deletions.
116 changes: 40 additions & 76 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ max_jobs: 100
cache:
- '%LOCALAPPDATA%\pip\Cache'

matrix:
allow_failures:
- USE_PYTEST: true

environment:
global:
MINGW_32: C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin
Expand All @@ -17,8 +21,14 @@ environment:
APPVEYOR_SAVE_CACHE_ON_ERROR: true
APPVEYOR_SKIP_FINALIZE_ON_EXIT: true
TEST_TIMEOUT: 1000
NPY_NUM_BUILD_JOBS: 4

matrix:
- PYTHON: C:\Python34-x64
PYTHON_VERSION: 3.4
PYTHON_ARCH: 64
USE_PYTEST: true

- PYTHON: C:\Python36
PYTHON_VERSION: 3.6
PYTHON_ARCH: 32
Expand All @@ -29,40 +39,11 @@ environment:
PYTHON_ARCH: 64
TEST_MODE: fast

- PYTHON: C:\Python34-x64
PYTHON_VERSION: 3.4
PYTHON_ARCH: 64
TEST_MODE: fast

- PYTHON: C:\Python36-x64
PYTHON_VERSION: 3.6
PYTHON_ARCH: 64
TEST_MODE: full

- PYTHON: C:\Python27
PYTHON_VERSION: 2.7
PYTHON_ARCH: 32
SKIP_NOTAG: true
TEST_MODE: full

- PYTHON: C:\Python34
PYTHON_VERSION: 3.4
PYTHON_ARCH: 32
SKIP_NOTAG: true
TEST_MODE: full

- PYTHON: C:\Python35-x64
PYTHON_VERSION: 3.5
PYTHON_ARCH: 64
SKIP_NOTAG: true
TEST_MODE: full

- PYTHON: C:\Python35
PYTHON_VERSION: 3.5
PYTHON_ARCH: 32
SKIP_NOTAG: true
TEST_MODE: full

init:
- "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%"
- "ECHO \"%APPVEYOR_SCHEDULED_BUILD%\""
Expand All @@ -74,22 +55,16 @@ init:
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
Write-Host "There are newer queued builds for this pull request, skipping build."
Exit-AppveyorBuild
raise "There are newer queued builds for this pull request, skipping build."
}
- ps: |
If (($env:SKIP_NOTAG -eq "true") -and ($env:APPVEYOR_REPO_TAG -ne "true")) {
Write-Host "Skipping build, not at a tag."
Exit-AppveyorBuild
}

install:
# Show size of cache
- C:\cygwin\bin\du -hs "%LOCALAPPDATA%\pip\Cache"
# Prepend newly installed Python to the PATH of this build (this cannot be
# done from inside the powershell script as it would require to restart
# the parent CMD process).
- SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
- if [%PYTHON_ARCH%]==[32] SET PATH=%MINGW_32%;%PATH% & SET OPENBLAS=%OPENBLAS_32%
- if [%PYTHON_ARCH%]==[64] SET PATH=%MINGW_64%;%PATH% & SET OPENBLAS=%OPENBLAS_64%

# Check that we have the expected version and architecture for Python
- python --version
Expand All @@ -101,72 +76,61 @@ install:
# Install "openblas.a" to PYTHON\lib
# Library provided by Matthew Brett at https://github.com/matthew-brett/build-openblas
- ps: |
$PYTHON_ARCH = $env:PYTHON_ARCH
$PYTHON = $env:PYTHON
If ($PYTHON_ARCH -eq 32) {
$OPENBLAS = $env:OPENBLAS_32
} Else {
$OPENBLAS = $env:OPENBLAS_64
}
$clnt = new-object System.Net.WebClient
$file = "$(New-TemporaryFile).zip"
$tmpdir = New-TemporaryFile | %{ rm $_; mkdir $_ }
$destination = "$PYTHON\lib\openblas.a"
$destination = "$env:PYTHON\lib\openblas.a"
echo $file
echo $tmpdir
echo $OPENBLAS
echo $env:OPENBLAS
$clnt.DownloadFile($OPENBLAS,$file)
$clnt.DownloadFile($env:OPENBLAS, $file)
Get-FileHash $file | Format-List
Expand-Archive $file $tmpdir
rm $tmpdir\$PYTHON_ARCH\lib\*.dll.a
$lib = ls $tmpdir\$PYTHON_ARCH\lib\*.a | ForEach { ls $_ } | Select-Object -first 1
rm $tmpdir\$env:PYTHON_ARCH\lib\*.dll.a
$lib = ls $tmpdir\$env:PYTHON_ARCH\lib\*.a | ForEach { ls $_ } | Select-Object -first 1
echo $lib
cp $lib $destination
ls $destination
# Upgrade to the latest pip.
- '%CMD_IN_ENV% python -m pip install -U pip setuptools wheel'
- 'python -m pip install -U pip setuptools wheel'

# Install the numpy test dependencies.
- '%CMD_IN_ENV% pip install -U --timeout 5 --retries 2 -r tools/ci/appveyor/requirements.txt'
- 'pip install -U --timeout 5 --retries 2 -r tools/ci/appveyor/requirements.txt'

build_script:
# Here, we add MinGW to the path to be able to link an OpenBLAS.dll
# We then use the import library from the DLL to compile with MSVC
- ps: |
$PYTHON_ARCH = $env:PYTHON_ARCH
If ($PYTHON_ARCH -eq 32) {
$MINGW = $env:MINGW_32
If ($env:USE_PYTEST -eq "true") {
pip install -e .
} Else {
$MINGW = $env:MINGW_64
}
$env:Path += ";$MINGW"
$env:NPY_NUM_BUILD_JOBS = "4"
mkdir dist
pip wheel -v -v -v --wheel-dir=dist .
# For each wheel that pip has placed in the "dist" directory
# First, upload the wheel to the "artifacts" tab and then
# install the wheel. If we have only built numpy (as is the case here),
# then there will be one wheel to install.
# This method is more representative of what will be distributed,
# because it actually tests what the built wheels will be rather than
# what 'setup.py install' will do and at it uploads the wheels so that
# they can be inspected.
ls dist -r | Foreach-Object {
appveyor PushArtifact $_.FullName
pip install $_.FullName
pip wheel -v -v -v --wheel-dir=dist .
# For each wheel that pip has placed in the "dist" directory
# First, upload the wheel to the "artifacts" tab and then
# install the wheel. If we have only built numpy (as is the case here),
# then there will be one wheel to install.
# This method is more representative of what will be distributed,
# because it actually tests what the built wheels will be rather than
# what 'setup.py install' will do and at it uploads the wheels so that
# they can be inspected.
ls dist -r | Foreach-Object {
appveyor PushArtifact $_.FullName
pip install $_.FullName
}
}
test_script:
- python runtests.py -v -n -m %TEST_MODE%
- if [%USE_PYTEST%]==[true] pytest -n3 --junitxml=junit-results.xml
- if [%USE_PYTEST%]==[] python runtests.py -v -n -m %TEST_MODE%

after_build:
# Remove old or huge cache files to hopefully not exceed the 1GB cache limit.
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ pmip
.sw[nop]
*.tmp
*.vim
.vscode
tags
cscope.out
# gnu global
GPATH
GRTAGS
GSYMS
GTAGS
.cache

# Compiled source #
###################
Expand Down Expand Up @@ -71,6 +73,7 @@ doc/cdoc/build
# The shelf plugin uses this dir
./.shelf
MANIFEST
.cache

# Paver generated files #
#########################
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# data, etc files to distribution. Avoid using MANIFEST.in for that.
#
include MANIFEST.in
include pytest.ini
include *.txt
include site.cfg.example
include numpy/random/mtrand/generate_mtrand_c.py
Expand Down
2 changes: 1 addition & 1 deletion doc/EXAMPLE_DOCSTRING.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Returns
-------
out : ndarray
The drawn samples, arranged according to `shape`. If the
shape given is (m,n,...), then the shape of `out` is is
shape given is (m,n,...), then the shape of `out` is
(m,n,...,N).

In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
Expand Down
48 changes: 47 additions & 1 deletion doc/release/1.15.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ New functions

* `np.gcd` and `np.lcm`, to compute the greatest common divisor and least
common multiple.
* `np.ma.stack`, the `np.stack` array-joining function generalized to masked
arrays.


Deprecations
Expand Down Expand Up @@ -53,7 +55,51 @@ builtin arbitrary-precision `Decimal` and `long` types.
Improvements
============

``histogram`` and ``histogramdd` functions have moved to ``np.lib.histograms``
------------------------------------------------------------------------------
These were originally found in ``np.lib.function_base``. They are still
available under their un-scoped ``np.histogram(dd)`` names, and
to maintain compatibility, aliased at ``np.lib.function_base.histogram(dd)``.

Code that does ``from np.lib.function_base import *`` will need to be updated
with the new location, and should consider not using ``import *`` in future.

``histogram`` will accept NaN values when explicit bins are given
-----------------------------------------------------------------
Previously it would fail when trying to compute a finite range for the data.
Since the range is ignored anyway when the bins are given explcitly, this error
was needless.

Note that calling `histogram` on NaN values continues to raise the
`RuntimeWarning`s typical of working with nan values, which can be silenced
as usual with `errstate`.

``histogram`` works on datetime types, when explicit bin edges are given
------------------------------------------------------------------------
Dates, times, and timedeltas can now be histogrammed. The bin edges must be
passed explicitly, and are not yet computed automatically.

``np.r_`` works with 0d arrays, and ``np.ma.mr_` works with ``np.ma.masked``
----------------------------------------------------------------------------
0d arrays passed to the `r_` and `mr_` concatenation helpers are now treated as
though they are arrays of length 1. Previously, passing these was an error.
As a result, ``np.ma.mr_`` now works correctly on the ``masked`` constant.

``np.ptp`` accepts a ``keepdims`` argument, and extended axis tuples
--------------------------------------------------------------------
``np.ptp`` (peak-to-peak) can now work over multiple axes, just like `max` and
`min`.

``MaskedArray.astype`` now is identical to ``ndarray.astype``
-------------------------------------------------------------
This means it takes all the same arguments, making more code written for
ndarray work for masked array too.

Enable AVX2/AVX512 at compile time
-------------------------------------------------------------
Change to simd.inc.src to use AVX2 or AVX512 at compile time. Solving the gap
that if compile numpy for avx2 (or 512) with -march=native, still get the SSE
code for the simd functions even though rest of the code gets AVX2.

Changes
=======

2 changes: 1 addition & 1 deletion doc/source/reference/c-api.coremath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ of floating point round-off error.

Like for other types, NumPy includes a typedef npy_half for the 16 bit
float. Unlike for most of the other types, you cannot use this as a
normal type in C, since is is a typedef for npy_uint16. For example,
normal type in C, since it is a typedef for npy_uint16. For example,
1.0 looks like 0x3c00 to C, and if you do an equality comparison
between the different signed zeros, you will get -0.0 != 0.0
(0x8000 != 0x0000), which is incorrect.
Expand Down
2 changes: 1 addition & 1 deletion numpy/add_newdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4055,7 +4055,7 @@ def luf(lamdaexpr, *args, **kwargs):

add_newdoc('numpy.core.multiarray', 'ndarray', ('ptp',
"""
a.ptp(axis=None, out=None)
a.ptp(axis=None, out=None, keepdims=False)
Peak to peak (maximum - minimum) value along a given axis.
Expand Down
32 changes: 32 additions & 0 deletions numpy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import warnings
import pytest
import numpy
import importlib

from numpy.core.multiarray_tests import get_fpu_mode

Expand Down Expand Up @@ -52,3 +54,33 @@ def check_fpu_mode(request):
raise AssertionError("FPU precision mode changed from {0:#x} to {1:#x}"
" when collecting the test".format(old_mode,
new_mode))


def pytest_addoption(parser):
parser.addoption("--runslow", action="store_true",
default=False, help="run slow tests")


def pytest_collection_modifyitems(config, items):
if config.getoption("--runslow"):
# --runslow given in cli: do not skip slow tests
return
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)


@pytest.fixture(autouse=True)
def add_np(doctest_namespace):
doctest_namespace['np'] = numpy


for module, replacement in {
'numpy.testing.decorators': 'numpy.testing.pytest_tools.decorators',
'numpy.testing.utils': 'numpy.testing.pytest_tools.utils',
}.items():
module = importlib.import_module(module)
replacement = importlib.import_module(replacement)
module.__dict__.clear()
module.__dict__.update(replacement.__dict__)
7 changes: 7 additions & 0 deletions numpy/core/_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,10 @@ def _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):
ret = um.sqrt(ret)

return ret

def _ptp(a, axis=None, out=None, keepdims=False):
return um.subtract(
umr_maximum(a, axis, None, out, keepdims),
umr_minimum(a, axis, None, None, keepdims),
out
)
Loading

0 comments on commit 56b3b66

Please sign in to comment.