Commit 19d66e31 authored by PIOLLE's avatar PIOLLE
Browse files

fixed append method

parent 422cf329
......@@ -208,7 +208,7 @@ class Feature(Dataset, ABC):
def append(self,
feature,
prefix: str = None,
prefix: str = '',
add_coords: bool = False,
as_new_dims: bool = False,
fields: str = None):
......@@ -254,28 +254,27 @@ class Feature(Dataset, ABC):
added_fields = feature.fieldnames
if add_coords:
added_fields.extend(feature.coordnames)
added_fields = list(set(added_fields))
# append fields
for fieldname in added_fields:
if fieldname in feature.fieldnames:
field = feature.get_field(fieldname).clone()
elif fieldname in feature.coords:
elif fieldname in feature.coordnames:
field = feature.get_coord(fieldname).clone()
else:
raise ValueError("field {} not found in feature".format(
fieldname))
if prefix is not None:
field.rename('{}{}'.format(prefix, field.name))
if as_new_dims:
# we ensure dim and field names can not be the same (raise an
# error with xarray
field._array = field._array.swap_dims(
{_: '{}_{}'.format(prefix, _) for _ in field.dims})
{_: '{}{}'.format(prefix, _) for _ in field.dims})
self.add_field(field)
def get_values(self, *args, **kwargs):
"""
See:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment