Repository: Qiskit/qiskit

Issue:
`exclude` and `filter` probably shouldn't rename my Schedule
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**:
- **Python version**:
- **Operating system**:

### What is the current behavior?

If I use the `exclude` or `filter` methods on a schedule, it modifies the name. This doesn't follow the behavior we've selected elsewhere, such as scheduling a circuit should keep the same name, or rescheduling a schedule should keep the same name, or appending, inserting etc should keep the name of the first schedule.

This is particularly an issue when I build a bunch of programs, use `exlude`, and later want to use the name I chose for my schedules to grab the result data back (it's something like `result.result().get_counts('name')`) -- if I pass the original name, then I can't get my data back, because I don't expect to need to pass `'name-excluded'`.

### Steps to reproduce the problem

Initialize a schedule with a name, call exclude, see that the name has changed

```
sched = Schedule(name='x')
sched.exclude(channels=[DriveChannel(0)])
sched.name
```

### What is the expected behavior?

`sched.name` should return `'x'` in the example above

### Suggested solutions

This can easily be fixed in `pulse.schedule:Schedule.exlude/filter`.


Thank you Jin-sung Kim for reporting!

`exclude` and `filter` probably shouldn't rename my Schedule
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**:
- **Python version**:
- **Operating system**:

### What is the current behavior?

If I use the `exclude` or `filter` methods on a schedule, it modifies the name. This doesn't follow the behavior we've selected elsewhere, such as scheduling a circuit should keep the same name, or rescheduling a schedule should keep the same name, or appending, inserting etc should keep the name of the first schedule.

This is particularly an issue when I build a bunch of programs, use `exlude`, and later want to use the name I chose for my schedules to grab the result data back (it's something like `result.result().get_counts('name')`) -- if I pass the original name, then I can't get my data back, because I don't expect to need to pass `'name-excluded'`.

### Steps to reproduce the problem

Initialize a schedule with a name, call exclude, see that the name has changed

```
sched = Schedule(name='x')
sched.exclude(channels=[DriveChannel(0)])
sched.name
```

### What is the expected behavior?

`sched.name` should return `'x'` in the example above

### Suggested solutions

This can easily be fixed in `pulse.schedule:Schedule.exlude/filter`.


Thank you Jin-sung Kim for reporting!



Discussion:

Resolving patch:
diff --git a/qiskit/pulse/schedule.py b/qiskit/pulse/schedule.py
--- a/qiskit/pulse/schedule.py
+++ b/qiskit/pulse/schedule.py
@@ -291,7 +291,7 @@ def filter(self, *filter_funcs: List[Callable],
                                                  time_ranges=time_ranges,
                                                  intervals=intervals)
         return self._apply_filter(composed_filter,
-                                  new_sched_name="{name}-filtered".format(name=self.name))
+                                  new_sched_name="{name}".format(name=self.name))
 
     def exclude(self, *filter_funcs: List[Callable],
                 channels: Optional[Iterable[Channel]] = None,
@@ -318,7 +318,7 @@ def exclude(self, *filter_funcs: List[Callable],
                                                  time_ranges=time_ranges,
                                                  intervals=intervals)
         return self._apply_filter(lambda x: not composed_filter(x),
-                                  new_sched_name="{name}-excluded".format(name=self.name))
+                                  new_sched_name="{name}".format(name=self.name))
 
     def _apply_filter(self, filter_func: Callable, new_sched_name: str) -> 'Schedule':
         """Return a Schedule containing only the instructions from this Schedule for which


Test patch:
diff --git a/test/python/pulse/test_schedule.py b/test/python/pulse/test_schedule.py
--- a/test/python/pulse/test_schedule.py
+++ b/test/python/pulse/test_schedule.py
@@ -521,6 +521,18 @@ def test_filter_channels(self):
         for _, inst in excluded.instructions:
             self.assertFalse(any([chan in channels for chan in inst.channels]))
 
+    def test_filter_exclude_name(self):
+        """Test the name of the schedules after applying filter and exclude functions."""
+        sched = Schedule(name='test-schedule')
+        sched = sched.insert(10, Acquire(5, AcquireChannel(0), MemorySlot(0)))
+        sched = sched.insert(10, Acquire(5, AcquireChannel(1), MemorySlot(1)))
+        excluded = sched.exclude(channels=[AcquireChannel(0)])
+        filtered = sched.filter(channels=[AcquireChannel(1)])
+
+        # check if the excluded and filtered schedule have the same name as sched
+        self.assertEqual(sched.name, filtered.name)
+        self.assertEqual(sched.name, excluded.name)
+
     def test_filter_inst_types(self):
         """Test filtering on instruction types."""
         lp0 = self.linear(duration=3, slope=0.2, intercept=0.1)