Skip to content

Commit aaa8c04

Browse files
committed
Modify fix and add dev comment
1 parent 6253fff commit aaa8c04

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/iris/pandas.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,14 @@ def _assert_shared(np_obj, pandas_obj):
130130
else:
131131
base = pandas_obj[0].base
132132

133-
if pandas_obj.values is np_obj:
134-
return
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+
135141
# Chase the stack of NumPy `base` references back to see if any of
136142
# them are our original array.
137143
while base is not None:

0 commit comments

Comments
 (0)