(
self,
classdict: dict[str, Any],
nestedlvl: int = -1,
validate: bool = True,
ptparams: dict[str, Any] | None = None,
)
| 463 | """ |
| 464 | |
| 465 | def __init__( |
| 466 | self, |
| 467 | classdict: dict[str, Any], |
| 468 | nestedlvl: int = -1, |
| 469 | validate: bool = True, |
| 470 | ptparams: dict[str, Any] | None = None, |
| 471 | ) -> None: |
| 472 | |
| 473 | if not classdict: |
| 474 | raise ValueError("cannot create an empty data type") |
| 475 | |
| 476 | # Do a shallow copy of classdict just in case this is going to |
| 477 | # be shared by other instances |
| 478 | newdict = self.__dict__ |
| 479 | newdict["_v_name"] = "/" # The name for root descriptor |
| 480 | newdict["_v_names"] = [] |
| 481 | newdict["_v_dtypes"] = {} |
| 482 | newdict["_v_types"] = {} |
| 483 | newdict["_v_dflts"] = {} |
| 484 | newdict["_v_colobjects"] = {} |
| 485 | newdict["_v_is_nested"] = False |
| 486 | nested_formats = [] |
| 487 | nested_dtype = [] |
| 488 | |
| 489 | if not hasattr(newdict, "_v_nestedlvl"): |
| 490 | newdict["_v_nestedlvl"] = nestedlvl + 1 |
| 491 | |
| 492 | cols_with_pos = [] # colum (position, name) pairs |
| 493 | cols_no_pos = [] # just column names |
| 494 | cols_offsets = [] # the offsets of the columns |
| 495 | valid_offsets = False # by default there a no valid offsets |
| 496 | |
| 497 | # Check for special variables and convert column descriptions |
| 498 | for name, descr in classdict.items(): |
| 499 | if name.startswith("_v_"): |
| 500 | if name in newdict: |
| 501 | # print("Warning!") |
| 502 | # special methods &c: copy to newdict, warn about conflicts |
| 503 | warnings.warn( |
| 504 | f"Can't set attr {name!r} in description " |
| 505 | f"class {self!r}" |
| 506 | ) |
| 507 | else: |
| 508 | # print("Special variable!-->", name, classdict[name]) |
| 509 | newdict[name] = descr |
| 510 | continue # This variable is not needed anymore |
| 511 | |
| 512 | columns = None |
| 513 | if type(descr) is type(IsDescription) and issubclass( |
| 514 | descr, IsDescription |
| 515 | ): |
| 516 | # print("Nested object (type I)-->", name) |
| 517 | columns = descr().columns |
| 518 | elif type(descr.__class__) is type(IsDescription) and issubclass( |
| 519 | descr.__class__, IsDescription |
| 520 | ): |
| 521 | # print("Nested object (type II)-->", name) |
| 522 | columns = descr.columns |
nothing calls this directly
no test coverage detected