Skip to content

Commit

Permalink
Merge pull request #1068 from jeromekelleher/reinstate-dump-compress
Browse files Browse the repository at this point in the history
Reinstate dump compress
  • Loading branch information
mergify[bot] authored Dec 1, 2020
2 parents feb0b53 + f4db427 commit bdb494e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
7 changes: 4 additions & 3 deletions python/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
--------------------
[0.X.X] - 2021-XX-XX
[0.3.4] - 2020-12-02
--------------------

**Breaking changes**
Minor bugfix release.

**Features**

**Bugfixes**

- Reinstate the unused zlib_compression option to tskit.dump, as msprime < 1.0
still uses it (:user:`jeromekelleher`, :issue:`1067`).

--------------------
[0.3.3] - 2020-11-27
Expand Down
10 changes: 10 additions & 0 deletions python/tests/test_highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,16 @@ def test_dump_load_errors(self):
with pytest.raises(TypeError):
func(bad_filename)

def test_zlib_compression_warning(self, ts_fixture, tmp_path):
temp_file = tmp_path / "tmp.trees"
with warnings.catch_warnings(record=True) as w:
ts_fixture.dump(temp_file, zlib_compression=True)
assert len(w) == 1
assert issubclass(w[0].category, RuntimeWarning)
with warnings.catch_warnings(record=True) as w:
ts_fixture.dump(temp_file, zlib_compression=False)
assert len(w) == 0

def test_tables_sequence_length_round_trip(self):
for sequence_length in [0.1, 1, 10, 100]:
ts = msprime.simulate(5, length=sequence_length, random_seed=1)
Expand Down
2 changes: 1 addition & 1 deletion python/tskit/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Definitive location for the version number.
# During development, should be x.y.z.devN
# For beta should be x.y.zbN
tskit_version = "0.3.4.dev1"
tskit_version = "0.3.4"
10 changes: 9 additions & 1 deletion python/tskit/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -3207,12 +3207,20 @@ def load_tables(cls, tables, *, build_indexes=False):
ts.load_tables(tables._ll_tables, build_indexes=build_indexes)
return TreeSequence(ts)

def dump(self, file_or_path):
def dump(self, file_or_path, zlib_compression=False):
"""
Writes the tree sequence to the specified path or file object.
:param str file_or_path: The file object or path to write the TreeSequence to.
:param bool zlib_compression: This parameter is deprecated and ignored.
"""
if zlib_compression:
# Note: the msprime CLI before version 1.0 uses this option, so we need
# to keep it indefinitely.
warnings.warn(
"The zlib_compression option is no longer supported and is ignored",
RuntimeWarning,
)
file, local_file = util.convert_file_like_to_open_file(file_or_path, "wb")
try:
self._ll_tree_sequence.dump(file)
Expand Down

0 comments on commit bdb494e

Please sign in to comment.