-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ABC Tests #10855
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
Closed
Closed
ABC Tests #10855
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,9 @@ | |
import nose | ||
from nose.tools import assert_equal, assert_true | ||
import numpy as np | ||
import pandas as pd | ||
from pandas.tslib import iNaT, NaT | ||
from pandas import Series, DataFrame, date_range, DatetimeIndex, Timestamp, Float64Index | ||
from pandas import Series, DataFrame, date_range, DatetimeIndex, Timestamp | ||
from pandas import compat | ||
from pandas.compat import range, long, lrange, lmap, u | ||
from pandas.core.common import notnull, isnull, array_equivalent | ||
|
@@ -40,6 +41,7 @@ def __getitem__(self): | |
|
||
assert(not is_seq(A())) | ||
|
||
|
||
def test_get_callable_name(): | ||
from functools import partial | ||
getname = com._get_callable_name | ||
|
@@ -49,6 +51,7 @@ def fn(x): | |
lambda_ = lambda x: x | ||
part1 = partial(fn) | ||
part2 = partial(part1) | ||
|
||
class somecall(object): | ||
def __call__(self): | ||
return x | ||
|
@@ -61,6 +64,45 @@ def __call__(self): | |
assert getname(1) is None | ||
|
||
|
||
def test_abc_types(): | ||
tuples = [('bar', 'one'), ('bar', 'two')] | ||
names = ['first', 'second'] | ||
values = [1, 2, 3, 4] | ||
index = pd.Index(['a', 'b', 'c']) | ||
int64_index = pd.Int64Index([1, 2, 3]) | ||
float64_index = pd.Float64Index([1, 2, 3]) | ||
multi_index = pd.MultiIndex.from_tuples(tuples, names=names) | ||
datetime_index = pd.to_datetime(['2000/1/1', '2010/1/1']) | ||
timedelta_index = pd.to_timedelta(np.arange(5), unit='s') | ||
period_index = pd.period_range('2000/1/1', '2010/1/1/', freq='M') | ||
categorical = pd.Categorical([1, 2, 3, 4], categories=[4, 2, 3, 1]) | ||
categorical_df = pd.DataFrame({"values": values}, index=categorical) | ||
categorical_index = categorical_df.index | ||
series = pd.Series(values) | ||
df = pd.DataFrame({"names": names}, index=multi_index) | ||
panel = df.to_panel() | ||
sparse_series = series.to_sparse() | ||
sparse_array = pd.SparseArray(np.random.randn(10)) | ||
period = pd.Period('2012', freq='A-DEC') | ||
assert(isinstance(index, com.ABCIndex)) | ||
assert(isinstance(int64_index, com.ABCInt64Index)) | ||
assert(isinstance(float64_index, com.ABCFloat64Index)) | ||
assert(isinstance(multi_index, com.ABCMultiIndex)) | ||
assert(isinstance(datetime_index, com.ABCDatetimeIndex)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create these as many of these inline as possible
|
||
assert(isinstance(timedelta_index, com.ABCTimedeltaIndex)) | ||
assert(isinstance(period_index, com.ABCPeriodIndex)) | ||
assert(isinstance(categorical_index, com.ABCCategoricalIndex)) | ||
assert(isinstance(index, com.ABCIndexClass)) | ||
assert(isinstance(int64_index, com.ABCIndexClass)) | ||
assert(isinstance(series, com.ABCSeries)) | ||
assert(isinstance(df, com.ABCDataFrame)) | ||
assert(isinstance(panel, com.ABCPanel)) | ||
assert(isinstance(sparse_series, com.ABCSparseSeries)) | ||
assert(isinstance(sparse_array, com.ABCSparseArray)) | ||
assert(isinstance(categorical, com.ABCCategorical)) | ||
assert(isinstance(period, com.ABCPeriod)) | ||
|
||
|
||
def test_notnull(): | ||
assert notnull(1.) | ||
assert not notnull(None) | ||
|
@@ -229,8 +271,6 @@ def test_array_equivalent(): | |
assert not array_equivalent(np.array([np.nan, 1, np.nan]), | ||
np.array([np.nan, 2, np.nan])) | ||
assert not array_equivalent(np.array(['a', 'b', 'c', 'd']), np.array(['e', 'e'])) | ||
assert array_equivalent(Float64Index([0, np.nan]), Float64Index([0, np.nan])) | ||
assert not array_equivalent(Float64Index([0, np.nan]), Float64Index([1, np.nan])) | ||
assert array_equivalent(DatetimeIndex([0, np.nan]), DatetimeIndex([0, np.nan])) | ||
assert not array_equivalent(DatetimeIndex([0, np.nan]), DatetimeIndex([1, np.nan])) | ||
|
||
|
@@ -942,7 +982,7 @@ def test_2d_float32(self): | |
|
||
def test_2d_datetime64(self): | ||
# 2005/01/01 - 2006/01/01 | ||
arr = np.random.randint(long(11045376), long(11360736), (5,3))*100000000000 | ||
arr = np.random.randint(long(11045376), long(11360736), (5, 3))*100000000000 | ||
arr = arr.view(dtype='datetime64[ns]') | ||
indexer = [0, 2, -1, 1, -1] | ||
|
||
|
@@ -1026,6 +1066,7 @@ def test_dict_compat(): | |
assert(com._dict_compat(expected) == expected) | ||
assert(com._dict_compat(data_unchanged) == data_unchanged) | ||
|
||
|
||
def test_possibly_convert_objects_copy(): | ||
values = np.array([1, 2]) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
self.assertIsInstance(obj, typ)