Repository: yt-project/yt

Issue:
missing declaration of used attribute?
### Bug report

while trying to load enzo data into yt (cf. python code below), we run into an issue that the (lazy?) loading in `yt.data_objects.DatasetSeries` is triggered when accessing `__get_item__ `of the resulting EnzoSimulation objects which fails with an AttributeError (cf. stacktrace below) for using `self.kwargs`. Afaik this attribute is only declared in `DatasetSeries.__init__` which itself is not invoked by its subclasses involved here (`yt.data_objects.SimulationTimeSeries` -> `yt.frontends.enzo.simulation_handling.EnzoSimulation`). Hence the loading failed.

**Code for reproduction**

```python
import yt
from yt.extensions.astro_analysis.halo_analysis import HaloCatalog
yt.enable_parallelism()
 
es = yt.load_simulation("/mnt/lustre/carla/Box100/RandomSeedStudy/Wunder-L4/parameter_file.txt", "Enzo", find_outputs=True)
 
hc = HaloCatalog(data_ds=es, finder_method='rockstar', finder_kwargs={"num_readers": 2, "num_writers": 4})
hc.create()
```

**Actual outcome**

```
File "/users/carla/scripts/run_rockstar-galaxies.py", line 9, in <module>
    hc.create()
  File "/opt/apps/pkgs/yt_astro_analysis/313cf31/intel64/gnu_9.1.0/cpython_3.8.9/lib/python3.8/site-packages/yt_astro_analysis/halo_analysis/halo_catalog/halo_catalog.py", line 333, in create
    self._run(save_halos, save_output,
  File "/opt/apps/pkgs/yt/4.0.dev0/intel64/gnu_9.1.0/cpython_3.8.9/lib/python3.8/site-packages/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 310, in barrierize
    retval = func(*args, **kwargs)
  File "/opt/apps/pkgs/yt_astro_analysis/313cf31/intel64/gnu_9.1.0/cpython_3.8.9/lib/python3.8/site-packages/yt_astro_analysis/halo_analysis/halo_catalog/halo_catalog.py", line 224, in _run
    self.finder_method(self)
  File "/opt/apps/pkgs/yt_astro_analysis/313cf31/intel64/gnu_9.1.0/cpython_3.8.9/lib/python3.8/site-packages/yt_astro_analysis/halo_analysis/halo_catalog/halo_finding_methods.py", line 39, in __call__
    return self.function(hc, *self.args, **self.kwargs)
  File "/opt/apps/pkgs/yt_astro_analysis/313cf31/intel64/gnu_9.1.0/cpython_3.8.9/lib/python3.8/site-packages/yt_astro_analysis/halo_analysis/halo_catalog/halo_finding_methods.py", line 87, in _rockstar_method
    rh = RockstarHaloFinder(ds, **finder_kwargs)
  File "/opt/apps/pkgs/yt_astro_analysis/313cf31/intel64/gnu_9.1.0/cpython_3.8.9/lib/python3.8/site-packages/yt_astro_analysis/halo_analysis/halo_finding/rockstar/rockstar.py", line 234, in __init__
    tds = ts[-1] # Cache a reference
  File "/opt/apps/pkgs/yt/4.0.dev0/intel64/gnu_9.1.0/cpython_3.8.9/lib/python3.8/site-packages/yt/data_objects/time_series.py", line 214, in __getitem__
    o = self._load(o, **self.kwargs)
P000 yt : [ERROR    ] 2021-04-14 15:27:09,625 AttributeError: 'EnzoSimulation' object has no attribute 'kwargs'
```

**Expected outcome**

well, I expect no AttributeError ;)

**Version Information**
  * Operating System: CentOS 7
  * Python Version: 3.8.9  (cpython)
  * yt version: 4.0.dev0 
  * Other Libraries (if applicable): yt_astro_analysis (latest commit on master i.e. 313cf31)

<!--Please tell us how you installed yt and python e.g., from source,
pip, conda. If you installed from conda, please specify which channel you used
if not the default-->

python itself as well as yt and yt_astro_analysis are compiled/installed from source. Supporting packages/dependencies (e.g. unyt) installed with pip. 

Thanks again for any help you can provide to clarify this issue.


Discussion:
Hi, and welcome to yt!  Thanks for opening your first issue.  We have an issue template that helps us to gather relevant information to help diagnosing and fixing the issue.

Hi @jschewts , thank you for reporting this. I'm sorry you didn't get a reply in 2 weeks. This definitely looks like a bug to me, though at the moment I'm not certain wether the issue is in yt itself or yt_astro_analysis (I'd be inclined towards yt itself though).
I'll try to have a look at this soon.
Update: indeed the `self.kwargs` attribute in `DatasetSeries` is only initialiazed in `DatasetSeries.__init__`, but not in `DatasetSeries.__new__`, which I _think_ explains the problem you're seeing here. I don't know the subtle differences between the two but it looks like you found one. I'll try to educate myself so I can fix it !

Resolving patch:
diff --git a/yt/data_objects/time_series.py b/yt/data_objects/time_series.py
--- a/yt/data_objects/time_series.py
+++ b/yt/data_objects/time_series.py
@@ -155,6 +155,7 @@ def __new__(cls, outputs, *args, **kwargs):
             pass
         ret = super().__new__(cls)
         ret._pre_outputs = outputs[:]
+        ret.kwargs = {}
         return ret
 
     def __init__(


Test patch: