Repository: ARM-software/mango

Issue:
Variable type issue in domain_space.py file
System: Ubuntu 18.04, Python; 3.8.8 (via conda environment), Tensorflow: 2.4.0 (with GPU), numpy: 1.18.5
Error happens when using TF in conjunction with Mango for neural architecture search.

In https://github.com/ARM-software/mango/blob/master/mango/domain/domain_space.py, line 120:
```
...
                    # we need to see the index where: domain[x] appears in mapping[x]
                    index = mapping_categorical[x].index(domain[x])
...
```
The variable mapping_categorical[x] automatically changes to numpy array for some iterations and remains as a list for some iterations. This causes an error: "numpy.ndarray() has no attribute index". I am not sure why the variable would return list for some iterations and a numpy array for other iterations. I made a workaround replacing the lines as follows:
```
...
                    # we need to see the index where: domain[x] appears in mapping[x]
                    if(type(mapping_categorical[x]).__name__ == 'list'):
                        index = mapping_categorical[x].index(domain[x])
                    else:
                        index = mapping_categorical[x].tolist().index(domain[x])
...
```




Discussion:

Patch:
diff --git a/mango/domain/domain_space.py b/mango/domain/domain_space.py
index 86cf9da..b02f833 100644
--- a/mango/domain/domain_space.py
+++ b/mango/domain/domain_space.py
@@ -70,7 +70,7 @@ class domain_space():
                 pass  # we are not doing anything at present, and will directly use its value for GP.
 
             elif isinstance(param_dict[par], range):
-                mapping_int[par] = param_dict[par]
+                mapping_int[par] = list(param_dict[par])
 
             elif isinstance(param_dict[par], Iterable):
 
@@ -83,11 +83,11 @@ class domain_space():
                     all_int = False
 
                 if all_int:
-                    mapping_int[par] = param_dict[par]
+                    mapping_int[par] = list(param_dict[par])
 
                 # For lists with mixed type, floats or strings we consider them categorical or discrete
                 else:
-                    mapping_categorical[par] = param_dict[par]
+                    mapping_categorical[par] = list(param_dict[par])
 
         self.mapping_categorical = mapping_categorical
         self.mapping_int = mapping_int


Test patch:
diff --git a/tests/test_domain_space.py b/tests/test_domain_space.py
index f0738de..1d5ae89 100644
--- a/tests/test_domain_space.py
+++ b/tests/test_domain_space.py
@@ -119,3 +119,17 @@ def test_gp_space():
 
     X2 = ds.convert_GP_space(params)
     assert np.isclose(X2, X).all()
+
+
+def test_np_space():
+    space = {
+        'x': np.array(['a', 'b', 'c']),
+        'y': np.arange(100),
+    }
+
+    ds = domain_space(space, domain_size=10)
+    params = ds.get_domain()
+    assert len(params) == 10
+
+    gp_params = ds.convert_GP_space(params)
+    assert gp_params.shape == (10, 4)
\ No newline at end of file