Circular calls between get_data and get_trajectory
Description
The get_data and _get_trajectory methods in base_data_container.py call each other in circular fasion:
def _get_trajectory(self, ...):
...
data = self.get_data(*new_tags, start=start, stop=stop, interval=interval)
...
def get_data(self, ...):
...
if 'trajectory' in tags:
...
return self._get_trajectory(*new_tags, start=start, stop=stop, interval=interval)
...
This increases code complexity and can lead to confusing behavior, in particular, since there is also a method called get_trajectory, which calls get_data:
def get_trajectory(self, ...):
return self.get_data('trajectory', start=start, stop=stop, interval=interval)
The latter function notably does not support any additional tags. Hence the following is OK
ret = get_data('trajectory', 'potential')
but not
ret = get_trajectory('potential')
This is quite confusing as noted earlier. For code quality and maintainability, this structure should be revised.
Suggestion
As a user, I would like to write
ret = get_trajectory() # to obtain only the trajectory
ret = get_trajectory('potential') # to obtain the trajectory with the 'potential' data
ret = get_data('potential') # to obtain the bare 'potential' data
As a user, I also find it not very intuitive that I have to type out 'trajectory' as a tag, which does not otherwise exist.
As a developer, I want to avoid circular calls.
One could for example move the interesting functionality (fill_method etc) into a private method, which is then called from either get_data or get_trajectory.