Skip to content

Conversation

@djkirkham
Copy link
Contributor

@djkirkham djkirkham commented Sep 8, 2016

This fixes the issue that now the _assert_shared function can't detect when a pandas object shares its data with a numpy array.

I'm not really happy with this solution. There's nothing in the pandas documentation that says values returns the original data object (indeed, in 0.16.2 it doesn't). But I can't find another way.

As an aside, a note in the doctring of _assert_shared as_series states

.. note::

   Pandas will sometimes make a copy of the array,
   for example when creating from an int32 array.
   Iris will detect this and raise an exception if copy=False.

This doesn't appear to be the case any more. At least, values always seems to return the original array, and the buffer objects of a pandas.Series and the NumPy array from which it was created always seem to point to the same location in memory, if cope=False is specified.

@djkirkham djkirkham mentioned this pull request Sep 8, 2016
base = pandas_obj[0].base

if pandas_obj.values is np_obj:
return
Copy link
Member

Choose a reason for hiding this comment

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

please add a comment around this change, explaining why the change is needed and referencing pandas versions as appropriate

I would like to see just enough about the pandas implementation change to be able to understand the change if I came back to it

@marqh
Copy link
Member

marqh commented Sep 14, 2016

this looks fine
thank you @djkirkham

@marqh marqh merged commit 2ac14cb into SciTools:master Sep 14, 2016
@djkirkham djkirkham deleted the fix-pandas-errors branch September 14, 2016 15:07
@QuLogic QuLogic added this to the v2.0 milestone Sep 14, 2016
@QuLogic QuLogic modified the milestones: v2.0, v1.11 Oct 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants