From 2646fe1af9024f9b923588b3714b9c360a31a9de Mon Sep 17 00:00:00 2001 From: Mathias Bustamante Date: Thu, 12 Sep 2019 11:34:32 -0500 Subject: [PATCH 1/2] when creating a variable with create_variable() and passing subvariables with id and alias, respect those in favor of default values generated by Crunch --- scrunch/datasets.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scrunch/datasets.py b/scrunch/datasets.py index 49906de..5a07d21 100644 --- a/scrunch/datasets.py +++ b/scrunch/datasets.py @@ -1703,9 +1703,14 @@ def create_variable(self, var_type, name, alias=None, description='', if categories: payload['categories'] = categories if subvariables: - payload['subreferences'] = [ - {'name': item['name']} for item in subvariables - ] + payload['subreferences'] = [] + for item in subvariables: + subrefs = {'name': item['name']} + if item.get('alias'): + subrefs['alias'] = item['alias'] + if item.get('id'): + subrefs['id'] = item['id'] + payload['subreferences'].append(subrefs) if values: payload['values'] = values From aeb116222b2cb1fc9a4b36ef975b617a5415590a Mon Sep 17 00:00:00 2001 From: Mathias Bustamante Date: Fri, 13 Sep 2019 09:50:32 -0500 Subject: [PATCH 2/2] Removing id from subvariables create_variable() method. Crunch will ignore it anyways --- scrunch/datasets.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scrunch/datasets.py b/scrunch/datasets.py index 5a07d21..1164f98 100644 --- a/scrunch/datasets.py +++ b/scrunch/datasets.py @@ -1708,8 +1708,6 @@ def create_variable(self, var_type, name, alias=None, description='', subrefs = {'name': item['name']} if item.get('alias'): subrefs['alias'] = item['alias'] - if item.get('id'): - subrefs['id'] = item['id'] payload['subreferences'].append(subrefs) if values: payload['values'] = values