Skip to content

Commit bd305ce

Browse files
authored
fixed header repr for empty headers (#94)
* #93 fixes bug * #93 added test * Changelog and version
1 parent 5159a6d commit bd305ce

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# TFS-Pandas Changelog
22

3+
## Version 3.0.2
4+
5+
- Fixed:
6+
- String representation of empty headers is fixed (accidentally printed 'None' before).
7+
8+
## Version 3.0.1
9+
10+
- Fixed:
11+
- Merging functionality from `TfsDataFrame.append`, `TfsDataFrame.join`, `TfsDataFrame.merge` and `tfs.concat` do not crash anymore when encountering a `pandas.DataFrame` (or more for `tfs.concat`) in their input. Signatures have been updated and tests were added for this behavior.
12+
13+
## Version 3.0.0
14+
15+
A long-standing issue where merging functionality used on `TfsDataFrame` (through `.merge` or `pandas.concat` for instance) would cause them to be cast back to `pandas.DataFrame` and lose their headers has been patched.
16+
17+
- Breaking changes:
18+
- The internal API has been reworked for clarity and consistency. Note that anyone previously using the high-level exports `tfs.read`, `tfs.write` and `tfs.TfsDataFrame` **will not be affected**.
19+
20+
- Added:
21+
- The `TfsDataFrame` class now has new `.append`, `.join` and `.merge` methods wrapping the inherited methods of the same name and fixing the aforementioned issue.
22+
- A `tfs.frame.concat` function, exported as `tfs.concat`, has been added to wrap `pandas.concat` and fix the aforementioned issue.
23+
- A `tfs.frame.merge_headers` function has been added.
24+
- Top level exports are now: `tfs.TfsDataFrame`, `tfs.read`, `tfs.write` and `tfs.concat`.
25+
26+
- Changes:
27+
- The `tfs.frame.validate` function is now a public-facing documented API and may be used stably.
28+
- The `write_tfs` function now appends an `EOL` (`\n`) at the end of the file when writing out for visual clarity and readability. This is a purely cosmetic and **does not** change functionality / compatibility of the files.
29+
- Documentation and README have been updated and cleared up.
30+
31+
Please do refer to the documentation for the use of the new merging functionality to be aware of caveats, especially when merging headers.
32+
33+
334
## Version 2.1.0
435

536
- Changes:

tests/test_frame.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ def test_long_headers_print(self):
9797
assert not all(str(val) in print_out for val in headers.values())
9898
assert "..." in print_out
9999

100+
def test_empty_headers_print(self):
101+
print_tfs = str(TfsDataFrame())
102+
print_df = str(pd.DataFrame())
103+
assert print_tfs == print_df.replace(pd.DataFrame.__name__, TfsDataFrame.__name__)
104+
100105

101106
class TestTfsDataFrameAppending:
102107
@pytest.mark.parametrize("how_headers", [None, "left", "right"])

tfs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
__title__ = "tfs-pandas"
1010
__description__ = "Read and write tfs files."
1111
__url__ = "https://github.com/pylhc/tfs"
12-
__version__ = "3.0.1"
12+
__version__ = "3.0.2"
1313
__author__ = "pylhc"
1414
__author_email__ = "[email protected]"
1515
__license__ = "MIT"

tfs/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _str_items(items_list: Sequence[str]) -> str:
7575
else:
7676
s += f"{_str_items(self.headers.items())}\n"
7777
s += "\n"
78-
return s
78+
return s
7979

8080
def __repr__(self) -> str:
8181
headers_string = self._headers_repr()

0 commit comments

Comments
 (0)