Skip to content
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

Py3k unicode collapse #1832

Merged
merged 3 commits into from
Nov 11, 2015
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/iris/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,10 +968,11 @@ def collapsed(self, dims_to_collapse=None):
for index in np.ndindex(shape):
index_slice = (slice(None),) + tuple(index)
bounds.append(serialize(self.bounds[index_slice]))
dtype = np.dtype('S{}'.format(max(map(len, bounds))))
string_type_fmt = 'S{}' if six.PY2 else 'U{}'
dtype = np.dtype(string_type_fmt.format(max(map(len, bounds))))
bounds = np.array(bounds, dtype=dtype).reshape((1,) + shape)
points = serialize(self.points)
dtype = np.dtype('S{}'.format(len(points)))
dtype = np.dtype(string_type_fmt.format(len(points)))
Copy link
Member

Choose a reason for hiding this comment

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

string_type_fmt is only set if self.bounds is not None?

# Create the new collapsed coordinate.
coord = self.copy(points=np.array(points, dtype=dtype),
bounds=bounds)
Expand Down