Skip to content

Commit

Permalink
test for pd.DataFrame + headers provided to writing
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoubelet committed Dec 20, 2024
1 parent f9d39b6 commit d56e9e2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ def test_tfs_write_no_headers_dataframe(self, tmp_path, _pd_dataframe):
# headers present in the former the check would fail
assert_frame_equal(df, new, check_frame_type=False)

def test_tfs_write_validate_with_pandas_and_headers_dict(self, tmp_path, _pd_dataframe):
# We make sure that if provided with a pandas.DataFrame and a headers_dict
# the validation and writing go as expected.
df = _pd_dataframe
headers = {"Title": "Tfs Title", "Value": 3.3663}
write_tfs(tmp_path / "temporary.tfs", df, headers_dict=headers, validate="madx")
new = read_tfs(tmp_path / "temporary.tfs", validate="madx")
# Here we use the asserts from pandas as we need to check individually for
# the dataframe itself and then the headers
assert_frame_equal(df, new, check_frame_type=False)
assert_dict_equal(headers, new.headers, compare_keys=True)

def test_tfs_write_read_with_path_in_headers(self, tmp_path, _tfs_dataframe):
# We will insert a pathlib.Path in the headers and ensure it is
# written as a string, in its current (relative in this case) form
Expand Down

0 comments on commit d56e9e2

Please sign in to comment.