Skip to content

Fix deprecation warnings - #2552

Merged
jeromekelleher merged 5 commits into
tskit-dev:mainfrom
jwgarber:fix-warnings
Oct 31, 2026
Merged

jeromekelleher merged 5 commits into
tskit-dev:mainfrom
jwgarber:fix-warnings

Conversation

@jwgarber

Copy link
Copy Markdown
Contributor

Hello! This fixes various deprecation warnings I ran into when going through the development guide. Most of them were in the python tests, which I've listed below for reference. More details about the fix for each are given in the commit messages.

tests/test_cli.py: 46 warnings
  /home/jacob/gsoc/msprime/msprime/cli.py:139: PendingDeprecationWarning: FileType is deprecated. Simply open files after parsing arguments.
    type=argparse.FileType("wb"),

tests/test_cli.py: 23 warnings
  /home/jacob/gsoc/msprime/msprime/cli.py:1147: PendingDeprecationWarning: FileType is deprecated. Simply open files after parsing arguments.
    type=argparse.FileType("rb"),

tests/test_cli.py::TestMspSimulateOutput::test_compress_warns
  /home/jacob/gsoc/msprime/msprime/cli.py:1301: UserWarning: The simulate command is deprecated but will continue to work indefinitely. To simulate ancestries, please use the 'ancestry' command. To place mutations on a tree sequence, please use the 'mutations' command.
    args.runner(args)

tests/test_mutations.py::TestMutationModelFactory::test_returns_mutation_model_instances_without_copying
tests/test_mutations.py::TestModelClasses::test_slim
  /home/jacob/gsoc/msprime/msprime/mutations.py:162: FutureWarning: SLiMMutationModel will be removed in future versions. Use SLiMv5MutationModel or SLiMv6MutationModel instead.
    warnings.warn(

tests/test_simulate_from.py::TestBasicFunctionality::test_from_wf_nonoverlapping
tests/test_simulate_from.py::TestBasicFunctionality::test_from_wf_overlapping
tests/test_simulate_from.py::TestSimAncestryInterface::test_extra_pops_missing_extra_metadata
tests/test_simulate_from.py::TestSlimOutput::test_minimal_example_no_recombination
tests/test_simulate_from.py::TestSlimOutput::test_minimal_example_recombination
tests/test_simulate_from.py::TestSlimOutput::test_single_locus_example_no_recombination
tests/test_simulate_from.py::TestSlimOutput::test_single_locus_example_recombination
tests/test_simulate_from.py::TestBugExamples::test_unordered_tables_on_output
  /home/jacob/gsoc/msprime/msprime/ancestry.py:1297: TimeUnitsMismatchWarning: The initial_state has time_units=unknown but time is measured in generations in msprime. This may lead to significant discrepancies between the timescales. If you wish to suppress this warning, you can use, e.g., warnings.simplefilter('ignore', msprime.TimeUnitsMismatchWarning)
    sim = _parse_sim_ancestry(

tests/test_ancestry.py::TestParseSimAncestry::test_sequence_length
  /home/jacob/gsoc/msprime/tests/test_ancestry.py:1172: TimeUnitsMismatchWarning: The initial_state has time_units=unknown but time is measured in generations in msprime. This may lead to significant discrepancies between the timescales. If you wish to suppress this warning, you can use, e.g., warnings.simplefilter('ignore', msprime.TimeUnitsMismatchWarning)
    sim = ancestry._parse_sim_ancestry(

This class has been deprecated in Python 3.14, replace it with
a similar function as suggested on the github issue.

python/cpython#58032
There is already a dedicated test that runs this model using the
deprecated alias, so switch to v5 in the other locations to
silence the warnings.
The capture_output function in this class ignores the deprecation
warning, and so we need to call it for this test like the others do.
These tests ignore IncompletePopulationMetadataWarning, so ignore
TimeUnitsMismatchWarning as well.
Usage without setup is deprecated
@jeromekelleher

Copy link
Copy Markdown
Member

Thanks @jwgarber !

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.82%. Comparing base (f5d1e33) to head (571584e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2552   +/-   ##
=======================================
  Coverage   93.82%   93.82%           
=======================================
  Files          20       20           
  Lines       12225    12231    +6     
  Branches     2254     2255    +1     
=======================================
+ Hits        11470    11476    +6     
  Misses        574      574           
  Partials      181      181           
Flag Coverage Δ
C 84.14% <ø> (ø)
c-python 72.74% <ø> (ø)
python-tests 98.59% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Python API 98.61% <100.00%> (+<0.01%) ⬆️
Python C interface 92.88% <ø> (ø)
C library 91.05% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jeromekelleher
jeromekelleher added this pull request to the merge queue Oct 31, 2026
Merged via the queue into tskit-dev:main with commit 0d2c3be Oct 31, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants