Skip to content

Commit

Permalink
add a None (becomes nil) in the _tfs_dataframe_madng fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoubelet committed Dec 19, 2024
1 parent 5ca050a commit 01ce775
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def _tfs_dataframe_madng() -> TfsDataFrame:
"Title": "MADNG Test",
"Bool1": True,
"Bool2": False,
"A_NIL": None,
"Complex1": 19.3 + 39.4j,
"Complex2": -94.6 - 67.9j,
},
Expand Down
8 changes: 4 additions & 4 deletions tfs/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ def _get_header_line(name: str, value, width: int) -> str:
errmsg = f"{name} is not a string"
raise TypeError(errmsg)
type_identifier = _value_to_type_identifier(value)
dtype_ = np.array(value).dtype
value_str = ValueToStringFormatter().format_field(value, _dtype_to_formatter_string(dtype_, width))
print(f"Determined value string is {value_str}")
return f"@ {name:<{width}} {type_identifier} {value_str:>{width}}".strip()
dtype_ = NoneType if value is None else np.array(value).dtype # otherwise numpy gives 'Object' for 'None's
# Strip the following as it might have trailing spaces and we leave that to the alignment formatting below
value_str = ValueToStringFormatter().format_field(value, _dtype_to_formatter_string(dtype_, width)).strip()
return f"@ {name:<{width}} {type_identifier} {value_str.strip():>{width}}"


def _get_colnames_string(colnames: list[str], colwidth: int, left_align_first_column: bool) -> str: # noqa: FBT001
Expand Down

0 comments on commit 01ce775

Please sign in to comment.