Skip to content

Commit 2ac14cb

Browse files
djkirkhammarqh
authored andcommitted
Fix _assert_shared (#2136)
* Fix _assert_shared
1 parent 2763b56 commit 2ac14cb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/iris/pandas.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# (C) British Crown Copyright 2013 - 2015, Met Office
1+
# (C) British Crown Copyright 2013 - 2016, Met Office
22
#
33
# This file is part of Iris.
44
#
@@ -129,6 +129,15 @@ def _assert_shared(np_obj, pandas_obj):
129129
base = pandas_obj.base
130130
else:
131131
base = pandas_obj[0].base
132+
133+
# Prior to Pandas 0.17, when pandas_obj is a Series, pandas_obj.values
134+
# returns a view of the underlying array, and pandas_obj.base, which calls
135+
# pandas_obj.values.base, returns the underlying array. In 0.17 and 0.18
136+
# pandas_obj.values returns the underlying array, so base may be None even
137+
# if the array is shared.
138+
if base is None:
139+
base = pandas_obj.values
140+
132141
# Chase the stack of NumPy `base` references back to see if any of
133142
# them are our original array.
134143
while base is not None:

0 commit comments

Comments
 (0)