@@ -152,7 +152,7 @@ def _get_aggregator(self):
152152import logging
153153import warnings
154154from functools import partial
155- from typing import Iterable , Union
155+ from collections . abc import Iterable
156156
157157import numpy as np
158158from .. import coordinates
@@ -164,6 +164,7 @@ def _get_aggregator(self):
164164 BackendMultiprocessing ,
165165 BackendSerial ,
166166 BackendBase ,
167+ DefaultBackendOptions ,
167168)
168169from .results import Results , ResultsGroup
169170
@@ -352,7 +353,7 @@ def __init__(self, trajectory, verbose=False, **kwargs):
352353
353354 def _define_run_frames (
354355 self , trajectory , start = None , stop = None , step = None , frames = None
355- ) -> Union [ slice , np .ndarray ] :
356+ ) -> slice | np .ndarray :
356357 """Defines limits for the whole run, as passed by self.run() arguments
357358
358359 Parameters
@@ -371,7 +372,7 @@ def _define_run_frames(
371372
372373 Returns
373374 -------
374- Union[ slice, np .ndarray]
375+ slice or numpy .ndarray
375376 Appropriate slicer for the trajectory that would give correct iteraction
376377 order via trajectory[slicer]
377378
@@ -399,14 +400,14 @@ def _define_run_frames(
399400 self .start , self .stop , self .step = start , stop , step
400401 return slicer
401402
402- def _prepare_sliced_trajectory (self , slicer : Union [ slice , np .ndarray ] ):
403+ def _prepare_sliced_trajectory (self , slicer : slice | np .ndarray ):
403404 """Prepares sliced trajectory for use in subsequent parallel computations:
404405 namely, assigns self._sliced_trajectory and its appropriate attributes,
405406 self.n_frames, self.frames and self.times.
406407
407408 Parameters
408409 ----------
409- slicer : Union[ slice, np .ndarray]
410+ slicer : slice or numpy .ndarray
410411 appropriate slicer for the trajectory
411412
412413
@@ -511,7 +512,7 @@ def _conclude(self):
511512 def _compute (
512513 self ,
513514 indexed_frames : np .ndarray ,
514- verbose : bool = None ,
515+ verbose : bool | None = None ,
515516 * ,
516517 progressbar_kwargs = None ,
517518 ) -> "AnalysisBase" :
@@ -520,8 +521,8 @@ def _compute(
520521
521522 Parameters
522523 ----------
523- indexed_frames : np .ndarray
524- np .ndarray of (n, 2) shape, where first column is frame iteration
524+ indexed_frames : numpy .ndarray
525+ numpy .ndarray of (n, 2) shape, where first column is frame iteration
525526 indices and second is frame numbers
526527
527528 verbose : bool, optional
@@ -567,10 +568,10 @@ def _compute(
567568 def _setup_computation_groups (
568569 self ,
569570 n_parts : int ,
570- start : int = None ,
571- stop : int = None ,
572- step : int = None ,
573- frames : Union [ slice , np .ndarray ] = None ,
571+ start : int | None = None ,
572+ stop : int | None = None ,
573+ step : int | None = None ,
574+ frames : slice | np .ndarray | None = None ,
574575 ) -> list [np .ndarray ]:
575576 """
576577 Splits the trajectory frames, defined by ``start/stop/step`` or
@@ -600,7 +601,7 @@ def _setup_computation_groups(
600601
601602 Returns
602603 -------
603- computation_groups : list[np .ndarray]
604+ computation_groups : list[numpy .ndarray]
604605 list of (n, 2) shaped np.ndarrays with frame indices and numbers
605606
606607
@@ -638,7 +639,7 @@ def _setup_computation_groups(
638639
639640 def _configure_backend (
640641 self ,
641- backend : Union [ str , BackendBase ] ,
642+ backend : DefaultBackendOptions | BackendBase ,
642643 n_workers : int ,
643644 unsupported_backend : bool = False ,
644645 ) -> BackendBase :
@@ -648,7 +649,7 @@ def _configure_backend(
648649
649650 Parameters
650651 ----------
651- backend : Union[ str, BackendBase]
652+ backend : str or BackendBase
652653 backend to be used:
653654 - ``str`` is matched to a builtin backend (one of "serial",
654655 "multiprocessing" and "dask")
@@ -758,14 +759,14 @@ def _configure_backend(
758759
759760 def run (
760761 self ,
761- start : int = None ,
762- stop : int = None ,
763- step : int = None ,
764- frames : Iterable = None ,
765- verbose : bool = None ,
766- n_workers : int = None ,
767- n_parts : int = None ,
768- backend : Union [ str , BackendBase ] = None ,
762+ start : int | None = None ,
763+ stop : int | None = None ,
764+ step : int | None = None ,
765+ frames : Iterable | None = None ,
766+ verbose : bool | None = None ,
767+ n_workers : int | None = None ,
768+ n_parts : int | None = None ,
769+ backend : DefaultBackendOptions | BackendBase | None = None ,
769770 * ,
770771 unsupported_backend : bool = False ,
771772 progressbar_kwargs = None ,
@@ -796,15 +797,15 @@ def run(
796797 ProgressBar keywords with custom parameters regarding progress bar
797798 position, etc; see :class:`MDAnalysis.lib.log.ProgressBar`
798799 for full list. Available only for ``backend='serial'``
799- backend : Union[ str, BackendBase] , optional
800+ backend : str or BackendBase, optional
800801 By default, performs calculations in a serial fashion.
801802 Otherwise, user can choose a backend: ``str`` is matched to a
802803 builtin backend (one of ``serial``, ``multiprocessing`` and
803804 ``dask``), or a :class:`MDAnalysis.analysis.results.BackendBase`
804805 subclass.
805806
806807 .. versionadded:: 2.8.0
807- n_workers : int
808+ n_workers : int, optional
808809 positive integer with number of workers (processes, in case of
809810 built-in backends) to split the work between
810811
0 commit comments