Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Quantity into scalar and sequence classes #764

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3ad6e39
create quantityscalar and sequence classes
andrewgsavage Feb 12, 2019
0d0097d
add __array_function__
andrewgsavage Feb 14, 2019
cfc5d0d
Merge branch 'master' into split_quantity
andrewgsavage Feb 16, 2019
431d5b4
replace _Q with BaseQuantity
andrewgsavage Feb 16, 2019
f62e946
change np ufuncs to check x2 is a BaseQuantity
andrewgsavage Feb 17, 2019
bbb44d6
revert changes in test_quantity
andrewgsavage Feb 17, 2019
d76171f
revert some more
andrewgsavage Feb 17, 2019
30d542a
some more reverts
andrewgsavage Feb 17, 2019
5b9e473
revert more
andrewgsavage Feb 17, 2019
c21bfbd
revert getattr
andrewgsavage Feb 18, 2019
def8348
__used -> _used
andrewgsavage Feb 19, 2019
65905e0
fix path without _used
andrewgsavage Feb 19, 2019
7fb3800
fix setitem
andrewgsavage Feb 20, 2019
e07e237
fix put
andrewgsavage Feb 20, 2019
f6373fb
some array manip tests
andrewgsavage Feb 21, 2019
0aea9bc
remove broadcast
andrewgsavage Feb 21, 2019
077d12b
atleast nd
andrewgsavage Feb 21, 2019
da9dcb8
squuze
andrewgsavage Feb 21, 2019
2727d21
uprev numpy, disable less useful versions
andrewgsavage Feb 21, 2019
fef52dd
downrev numpy to one that may exist
andrewgsavage Feb 21, 2019
ba8cfe1
downrev numpy to one that may exist
andrewgsavage Feb 22, 2019
2f507f0
test dev numpy
andrewgsavage Feb 22, 2019
7c90ba7
test dev numpy
andrewgsavage Feb 22, 2019
f0b904e
pre release wheels
andrewgsavage Feb 22, 2019
4123d14
few more funcs
andrewgsavage Feb 23, 2019
ca0ecfd
try to get tests green
andrewgsavage Feb 24, 2019
3923c44
better way of skippping tests for other np versions
andrewgsavage Feb 24, 2019
1f4cd7f
set up np version for dev versions
andrewgsavage Feb 24, 2019
247700e
few more funcs
andrewgsavage Feb 24, 2019
284fe70
remove unexpected failure
andrewgsavage Feb 24, 2019
337e151
add more subclassed unexpected failure functions
andrewgsavage Feb 24, 2019
2f741a3
organise np tests
andrewgsavage Feb 25, 2019
d16f820
add Joining arrays tests/funcs
andrewgsavage Feb 25, 2019
0a84003
get unwrap workin
andrewgsavage Feb 25, 2019
346e0b4
rationalise conversion helper funcs
andrewgsavage Feb 25, 2019
67918ec
single implementation function
andrewgsavage Feb 25, 2019
afc7051
implement remaining subclass funcs
andrewgsavage Feb 26, 2019
e32e6e9
try testing np 1.16
andrewgsavage Mar 7, 2019
4dcbe78
.
andrewgsavage Mar 18, 2019
6c62a05
offset units
andrewgsavage Jul 28, 2019
a7f5841
Merge branch 'master' into split_quantity
andrewgsavage Jul 28, 2019
b57f012
add warning
andrewgsavage Aug 17, 2019
d3195d1
add warning
andrewgsavage Aug 17, 2019
d9ef27d
add warning
andrewgsavage Aug 17, 2019
ea6bebe
add warning
andrewgsavage Aug 17, 2019
aa66a07
add warning
andrewgsavage Aug 17, 2019
5a528ad
Merge pull request #5 from andrewgsavage/ags/split_quantity2
andrewgsavage Aug 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ branches:
env:
# Should pandas tests be removed or replaced wih import checks?
#- UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.14 PANDAS=1
- UNCERTAINTIES="N" PYTHON="3.3" NUMPY_VERSION=1.9.2 PANDAS=0
- UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.11.2 PANDAS=0
- UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=1.11.2 PANDAS=0
- UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.11.2 PANDAS=0
- UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.11.2 PANDAS=0
- UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=0 PANDAS=0
- UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=0 PANDAS=0
# Test with the latest numpy version
- UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=1.14 PANDAS=0
#- UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.14 PANDAS=0
- UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=1.14 PANDAS=0
- UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.14 PANDAS=0
- UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.14 PANDAS=0
- UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.17 PANDAS=0
- UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.16 PANDAS=0
# - UNCERTAINTIES="N" PYTHON="3.3" NUMPY_VERSION=1.9.2 PANDAS=0
# - UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.11.2 PANDAS=0
# - UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=1.11.2 PANDAS=0
# - UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.11.2 PANDAS=0
# - UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.11.2 PANDAS=0
# - UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=0 PANDAS=0
# - UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=0 PANDAS=0
# # Test with the latest numpy version
# - UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=1.14 PANDAS=0
# - UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.14 PANDAS=0
# - UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=1.14 PANDAS=0
# - UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.14 PANDAS=0
# - UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.14 PANDAS=0

before_install:
- sudo apt-get update
Expand Down Expand Up @@ -51,7 +53,10 @@ install:
- conda create --yes -n $ENV_NAME python=$PYTHON pip
- source activate $ENV_NAME
- if [ $UNCERTAINTIES == 'Y' ]; then pip install 'uncertainties==2.4.7.1'; fi
- if [ $NUMPY_VERSION != '0' ]; then conda install --yes numpy==$NUMPY_VERSION; fi
# - if [ $NUMPY_VERSION != '0' ]; then conda install --yes numpy==$NUMPY_VERSION; fi
- pip install --upgrade pip setuptools wheel
- pip install cython
- pip install --pre --upgrade --timeout=60 -f https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com numpy
- if [[ $TRAVIS_PYTHON_VERSION == '3.5' && $NUMPY_VERSION == 1.11.2 && $UNCERTAINTIES == "Y" ]]; then pip install babel serialize pyyaml; fi
# this is superslow but suck it up until updates to pandas are made
- if [[ $PANDAS == '1' ]]; then pip install numpy cython pytest pytest-cov nbval; pip install git+https://github.com/pandas-dev/pandas.git@bdb7a1603f1e0948ca0cab011987f616e7296167; python -c 'import pandas; print(pandas.__version__)'; fi
Expand Down
29 changes: 28 additions & 1 deletion pint/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import sys

import warnings
from io import BytesIO
from numbers import Number
from decimal import Decimal
Expand Down Expand Up @@ -66,13 +67,35 @@ def u(x):
except ImportError:
from itertools import izip_longest as zip_longest

# TODO: remove this warning after v0.10
class BehaviorChangeWarning(UserWarning):
pass
_msg = ('The way pint handles numpy operations has changed. '
'Unimplemented numpy operations will now fail instead '
'of making assumptions about units. Some functions, '
'eg concat, will now return Quanties with units, where '
'they returned ndarrays previously. See '
'https://github.com/hgrecco/pint/pull/764 . '
'To hide this warning use the following code to import pint:'
"""

import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
import pint
---
""")

try:
import numpy as np
from numpy import ndarray

HAS_NUMPY = True
NUMPY_VER = np.__version__
NUMERIC_TYPES = (Number, Decimal, ndarray, np.number)

if "dev" in NUMPY_VER:
NUMPY_VER = NUMPY_VER[:NUMPY_VER.index("dev")-1]

def _to_magnitude(value, force_ndarray=False):
if isinstance(value, (dict, bool)) or value is None:
Expand All @@ -84,6 +107,10 @@ def _to_magnitude(value, force_ndarray=False):
if force_ndarray:
return np.asarray(value)
return value

warnings.warn(_msg, BehaviorChangeWarning)



except ImportError:

Expand Down Expand Up @@ -128,7 +155,7 @@ def _to_magnitude(value, force_ndarray=False):
import pandas as pd
HAS_PANDAS = True
# pin Pandas version for now
HAS_PROPER_PANDAS = pd.__version__.startswith("0.24.0.dev0+625.gbdb7a16")
HAS_PROPER_PANDAS = pd.__version__.startswith("0.25")
except ImportError:
HAS_PROPER_PANDAS = HAS_PANDAS = False

Expand Down
Loading