Skip to content

Fix osx tests #2935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,27 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install OSX libs
if: matrix.os == 'macos-latest'
run: |
brew install libxml2 libxslt

- name: Cache conda and dependencies
id: cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
c:\Miniconda\envs\anaconda-client-env
/usr/share/miniconda/envs/anaconda-client-env
~/osx-conda
~/.profile
key: ${{ runner.os }}-${{ matrix.python}}-conda-v12-${{ hashFiles('python/requirements/CI-tests-conda/requirements.txt') }}-${{ hashFiles('python/requirements/CI-tests-pip/requirements.txt') }}
path: ${{ env.CONDA }}/envs
key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.python}}-conda-v1-${{ hashFiles('python/requirements/CI-tests-conda/requirements.txt') }}-${{ hashFiles('python/requirements/CI-tests-pip/requirements.txt') }}

- name: Install Conda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
activate-environment: anaconda-client-env
python-version: ${{ matrix.python }}
channels: conda-forge
channel-priority: strict
auto-update-conda: true
use-only-tar-bz2: true

- name: Fix windows symlinks
working-directory: python
Expand Down Expand Up @@ -123,17 +123,8 @@ jobs:
run: |
pip install setuptools==57.5.0 #v58 broke some deps https://setuptools.pypa.io/en/latest/history.html#v58-0-0
pip install -r python/requirements/CI-tests-pip/requirements.txt

- name: Fix OSX Cache Write #OSX Won't let the cache restore due to file perms
if: steps.cache.outputs.cache-hit != 'true' && matrix.os == 'macos-latest'
run: |
cp -r /usr/local/miniconda/envs/anaconda-client-env ~/osx-conda

- name: Fix OSX Cache Restore
if: steps.cache.outputs.cache-hit == 'true' && matrix.os == 'macos-latest'
run: |
mkdir -p /usr/local/miniconda/envs
sudo cp -r ~/osx-conda /usr/local/miniconda/envs/anaconda-client-env
# Remove tskit installed by conda
pip uninstall -y tskit

- name: Build module
working-directory: python
Expand Down
2 changes: 0 additions & 2 deletions python/requirements/CI-tests-conda/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
msprime==1.2.0
kastore==0.3.2
jsonschema==4.16.0
h5py==3.7.0
2 changes: 2 additions & 0 deletions python/requirements/CI-tests-pip/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ networkx==3.1
msgpack==1.0.4
newick==1.3.2
tszip==0.2.2
kastore==0.3.2
lxml==4.9.2
8 changes: 5 additions & 3 deletions python/tests/test_balance_metrics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2022 Tskit Developers
# Copyright (c) 2024 Tskit Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -119,7 +119,7 @@ def test_b2(self, ts):
with pytest.raises(ValueError):
b2_index_definition(tree)
else:
assert tree.b2_index() == b2_index_definition(tree)
assert tree.b2_index() == pytest.approx(b2_index_definition(tree))

@pytest.mark.parametrize("ts", get_example_tree_sequences())
@pytest.mark.parametrize("base", [0.1, 1.1, 2, 10, math.e, np.array([3])[0]])
Expand All @@ -131,7 +131,9 @@ def test_b2_base(self, ts, base):
with pytest.raises(ValueError):
b2_index_definition(tree, base)
else:
assert tree.b2_index(base) == b2_index_definition(tree, base)
assert tree.b2_index(base) == pytest.approx(
b2_index_definition(tree, base)
)


class TestBalancedBinaryOdd:
Expand Down
10 changes: 7 additions & 3 deletions python/tests/test_ld_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ def test_sample_sets(partition):
:param partition: length 2 list of [ss_1, ss_2].
"""
ts = get_paper_ex_ts()
np.testing.assert_equal(
np.testing.assert_array_almost_equal(
ld_matrix(ts, sample_sets=partition), ts.ld_matrix(sample_sets=partition)
)

Expand All @@ -1055,7 +1055,9 @@ def test_multiallelic_with_back_mutation(stat):
samples=4, recombination_rate=0.2, sequence_length=10, random_seed=1
)
ts = msprime.sim_mutations(ts, rate=0.5, random_seed=1)
np.testing.assert_array_equal(ld_matrix(ts, stat=stat), ts.ld_matrix(stat=stat))
np.testing.assert_array_almost_equal(
ld_matrix(ts, stat=stat), ts.ld_matrix(stat=stat)
)


@pytest.mark.parametrize(
Expand All @@ -1068,7 +1070,9 @@ def test_multiallelic_with_back_mutation(stat):
)
@pytest.mark.parametrize("stat", SUMMARY_FUNCS.keys())
def test_ld_matrix(ts, stat):
np.testing.assert_array_equal(ld_matrix(ts, stat=stat), ts.ld_matrix(stat=stat))
np.testing.assert_array_almost_equal(
ld_matrix(ts, stat=stat), ts.ld_matrix(stat=stat)
)


@pytest.mark.parametrize(
Expand Down