Repository: wright-group/WrightTools

Issue:
save method of collection throws ValueError
I have a collection. I am attempting to save it, `col.save(filepath=p, overwrite=True)`. The following error is thrown:
```

  File "<ipython-input-12-664d233e4850>", line 1, in <module>
    runfile('/home/darien/source/MoS2_TSF/simulations/simulations.py', wdir='/home/darien/source/MoS2_TSF/simulations')

  File "/home/darien/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "/home/darien/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "/home/darien/source/MoS2_TSF/simulations/simulations.py", line 84, in <module>
    col.save(filepath=p, overwrite=True)

  File "/home/darien/source/WrightTools/WrightTools/_group.py", line 317, in save
    super().copy(v, new, name=v.natural_name)

  File "/home/darien/anaconda3/lib/python3.6/site-packages/h5py/_hl/group.py", line 399, in copy
    copypl, base.dlcpl)

  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper

  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper

  File "h5py/h5o.pyx", line 217, in h5py.h5o.copy

ValueError: Destination object already exists (destination object already exists)
```
The error gets thrown even if `simulations.wt5` does not exist at runtime. The `save` method creates the file on disk, but doesn't finish the job. 

I attempted to replicate the problem.
```
import numpy as np
import WrightTools as wt

x = np.linspace(0.1, 1, 10)
y = np.linspace(0.1, 1, 10)
z = x[:, None] * y[None, :]

root = wt.Collection(name='root')
d = root.create_data()

d.create_variable('x', values=x, units=None)
d.create_variable('y', values=y, units=None)
d.transform(['x', 'y'])
d.create_channel('z', values=z, units='p_nm')
    
p = 'testy.wt5'    
root.save(p, overwrite=True)
```
This script works *as expected* :disappointed: . 

In short, `save` is not working for me, but I can't nail down the problem. Feel free to checkout me in gitlab to see if you can replicate the problem with the same code I am using.
Should be the case that you can just clone and run `simulations/simulations.py`.


Discussion:
checking out your particular collection, I get the following:

```
sims (/tmp/qabgwydq.wt5)
├── 0: fit_ave (76,)
│   ├── axes: w (eV)
│   └── channels: N, u1, u2
├── 1: fit_ave (76,)
│   ├── axes: w (eV)
│   └── channels: N, u1, u2
├── 2: tsf (100, 100)
│   ├── axes: w1 (eV), w2 (eV)
│   └── channels: sig
└── 3: sim1D (200,)
    ├── axes: w (eV)
    └── channels: thg, shg, Abs
```

note that there are two data objects named `fit_ave`

the error is not to do with the _file_ already existing, but with the internal path already existing

this being said, I still believe this is a bug---probably introduced by #494... it seems like copy is adding two copies of the same data object into your collection

@ksunden can you handle this?
Confirmed this was introduced by #494 

Resolving patch:
diff --git a/WrightTools/_group.py b/WrightTools/_group.py
--- a/WrightTools/_group.py
+++ b/WrightTools/_group.py
@@ -264,9 +264,6 @@ def copy(self, parent=None, name=None, verbose=True):
         else:
             # copy
             self.file.copy(self.name, parent, name=name)
-            if 'item_names' in parent.attrs.keys():
-                new = parent.item_names + (name,)
-                parent.attrs['item_names'] = np.array(new, dtype='S')
             new = parent[name]
         # finish
         if verbose:


Test patch:
diff --git a/tests/group/save.py b/tests/group/save.py
--- a/tests/group/save.py
+++ b/tests/group/save.py
@@ -40,6 +40,7 @@ def test_copy_data():
     p = datasets.PyCMDS.wm_w2_w1_001
     data = wt.data.from_PyCMDS(p, parent=root, name='data')
     new = data.copy(parent=root, name='copy')
+    assert len(root.item_names) == 2
     for k, v in data.attrs.items():
         if k == 'name':
             continue