Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Implemented iterator for pandas.Series #125

Merged
merged 7 commits into from
Sep 14, 2019

Conversation

akharche
Copy link
Contributor

The first version of iterator for pandas.Series type:

  • Created separate SeriesIterator class
  • Implemented methods getiter and setiter depending on array type storing in Series
  • Created unit tests for this functionality

@@ -1485,6 +1485,30 @@ def test_impl():
hpat_func = hpat.jit(test_impl)
np.testing.assert_array_equal(hpat_func(), test_impl())

def test_series_iterator_int(self):
def test_impl():
A = pd.Series([1, 2, 3, 4, 5])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about constructing Series with unsorted list?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akharche Should we add tests with other types, like float and boolean as well? Will they be handled correctly now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@densmirn I think, it doesn't matter in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kozlov-alexey Yes, I am going to add by the next commit

hpat_func = hpat.jit(test_impl)
np.testing.assert_array_equal(hpat_func(), test_impl())

def test_series_iterator_one_value(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to add something like:

    def test_series_iterator_one_value(self):
        def test_impl(A):
            return [i for i in A]

        A = pd.Series([5])
        hpat_func = hpat.jit(test_impl)
        np.testing.assert_array_equal(hpat_func(A), test_impl(A))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akharche We may also check that empty series is handled correctly, by supplying
A = pd.Series([np.int64(x) for x in range(0)])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shssf I think yes, it is also important to check iteration over Series as a parameter. I will add this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kozlov-alexey Yes, I will add

@shssf
Copy link
Contributor

shssf commented Aug 16, 2019

@akharche Did you look for a code style for this by python ./setup.py style?

@akharche
Copy link
Contributor Author

@shssf Code style checks are ok for the changes

@shssf
Copy link
Contributor

shssf commented Sep 12, 2019

@akharche Is this PR ready to merge?

@shssf shssf merged commit 1c3b32d into IntelPython:master Sep 14, 2019
kozlov-alexey pushed a commit to kozlov-alexey/sdc that referenced this pull request Oct 4, 2019
* Implemented iterator for pandas.Series

* Add tests

* Fixed tests to run with mpi on 2 and more processes
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants