|
lsst.pipe.tasks g2c8cee2ce7+cc5eabfb3a
|
Functions | |
| str | _timestamp_precision_to_unit (int prec) |
| tuple[str, Any] | _felis_column_to_numpy_dtype (Mapping[str, Any] col) |
| np.dtype | felis_table_to_numpy_dtype (Mapping[str, Any] table) |
| str | pretty_print_dtype (np.dtype dtype, str table_name, int target_comment_col=36, int max_line_length=110) |
| main () | |
Variables | |
| list | DEFAULT_TABLES = ["SSObject", "SSSource", "mpc_orbits", "current_identifications", "numbered_identifications"] |
|
protected |
|
protected |
| np.dtype felis_table_to_numpy_dtype | ( | Mapping[str, Any] | table | ) |
| str pretty_print_dtype | ( | np.dtype | dtype, |
| str | table_name, | ||
| int | target_comment_col = 36, | ||
| int | max_line_length = 110 ) |
Pretty-print a structured NumPy dtype (with Felis-derived metadata)
as valid, readable Python code:
# Wrapped table description...
#
<table_name>Dtype = np.dtype([
('field1', '<i8'), # comment...
('very_long_field', ... # comment juts, next long field aligned
# to same jutter column...
])
Parameters
----------
dtype : np.dtype
Structured dtype with metadata fields:
metadata["description"] : table-level description (optional)
metadata["columns"] : {col_name: per-column description}
table_name : str
Name used for the assignment, e.g. <table_name>Dtype.
target_comment_col : int, default=36
Preferred starting column for comments when the field fits before it.
If the field text is longer than this, a "juttering group" alignment
logic kicks in to prevent jagged right edges.
max_line_length : int, default=110
Maximum line length for wrapping table descriptions and comments.
Lines will be wrapped to be strictly less than this length.
Behavior
--------
* Table description is wrapped to < max_line_length chars, placed above
dtype assignment, followed by a blank line.
* Field comments:
- If the field length <= target_comment_col - 1 → comment starts at
target_comment_col, and the "juttering group" resets.
- If the field length >= target_comment_col → the comment "juts out".
+ First such field sets the group's jutter column.
+ Next juttering fields use max(previous_jut_col, natural_jut_col).
+ This avoids jaggedness.
* Final lines never exceed max_line_length - 1 chars.
* Per-field comments wrap into at most 2 lines, with "..." if needed.
* dtype.metadata is NOT emitted; only used for comments.
Returns
-------
str
Pretty Python code string.