(
cls,
scalars,
*,
dtype: Dtype | None = None,
copy: bool = False,
)
| 266 | |
| 267 | @classmethod |
| 268 | def _from_sequence( |
| 269 | cls, |
| 270 | scalars, |
| 271 | *, |
| 272 | dtype: Dtype | None = None, |
| 273 | copy: bool = False, |
| 274 | ) -> Self: |
| 275 | if dtype is not None: |
| 276 | dtype = pandas_dtype(dtype) |
| 277 | if dtype and isinstance(dtype, PeriodDtype): |
| 278 | freq = dtype.freq |
| 279 | else: |
| 280 | freq = None |
| 281 | |
| 282 | if isinstance(scalars, cls): |
| 283 | validate_dtype_freq(scalars.dtype, freq) |
| 284 | if copy: |
| 285 | scalars = scalars.copy() |
| 286 | return scalars |
| 287 | |
| 288 | periods = np.asarray(scalars, dtype=object) |
| 289 | |
| 290 | freq = freq or libperiod.extract_freq(periods) |
| 291 | ordinals = libperiod.extract_ordinals(periods, freq) |
| 292 | dtype = PeriodDtype(freq) |
| 293 | return cls(ordinals, dtype=dtype) |
| 294 | |
| 295 | @classmethod |
| 296 | def _from_sequence_of_strings( |
no test coverage detected