Skip to content

Commit e16eabb

Browse files
committed
Merge branch 'master' into GH716_add_constructor_params
2 parents 23e2e7c + a39a3c1 commit e16eabb

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

malariagen_data/anoph/snp_frq.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import allel # type: ignore
55
import numpy as np
6+
import numpy.typing as npt
67
import pandas as pd
78
from numpydoc_decorator import doc # type: ignore
89
import xarray as xr
@@ -518,8 +519,8 @@ def snp_allele_frequencies_advanced(
518519

519520
# Set up main event variables.
520521
n_variants, n_cohorts = len(variant_position), len(df_cohorts)
521-
count = np.zeros((n_variants, n_cohorts), dtype=int)
522-
nobs = np.zeros((n_variants, n_cohorts), dtype=int)
522+
count: npt.NDArray[np.float64] = np.zeros((n_variants, n_cohorts), dtype=int)
523+
nobs: npt.NDArray[np.float64] = np.zeros((n_variants, n_cohorts), dtype=int)
523524

524525
# Build event count and nobs for each cohort.
525526
cohorts_iterator = self._progress(

malariagen_data/plasmodium.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import os
32

43
import dask.array as da
54
import pandas as pd
@@ -60,7 +59,7 @@ def sample_metadata(self):
6059
One row per sample.
6160
"""
6261
if self._cache_sample_metadata is None:
63-
path = os.path.join(self._path, self.CONF["metadata_path"])
62+
path = f"{self._path}/{self.CONF['metadata_path']}"
6463
with self._fs.open(path) as f:
6564
self._cache_sample_metadata = pd.read_csv(f, sep="\t", na_values="")
6665
return self._cache_sample_metadata
@@ -75,7 +74,7 @@ def _open_variant_calls_zarr(self):
7574
7675
"""
7776
if self._cache_variant_calls_zarr is None:
78-
path = os.path.join(self._path, self.CONF["variant_calls_zarr_path"])
77+
path = f"{self._path}/{self.CONF['variant_calls_zarr_path']}"
7978
store = init_zarr_store(fs=self._fs, path=path)
8079
self._cache_variant_calls_zarr = zarr.open_consolidated(store=store)
8180
return self._cache_variant_calls_zarr
@@ -205,7 +204,7 @@ def open_genome(self):
205204
206205
"""
207206
if self._cache_genome is None:
208-
path = os.path.join(self._path, self.CONF["reference_path"])
207+
path = f"{self._path}/{self.CONF['reference_path']}"
209208
store = init_zarr_store(fs=self._fs, path=path)
210209
self._cache_genome = zarr.open_consolidated(store=store)
211210
return self._cache_genome
@@ -317,7 +316,7 @@ def genome_features(self, attributes=("ID", "Parent", "Name")):
317316
try:
318317
df = self._cache_genome_features[attributes]
319318
except KeyError:
320-
path = os.path.join(self._path, self.CONF["annotations_path"])
319+
path = f"{self._path}/{self.CONF['annotations_path']}"
321320
with self._fs.open(path, mode="rb") as f:
322321
df = read_gff3(f, compression="gzip")
323322
if attributes is not None:

tests/anoph/test_hap_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ def test_haplotypes_virtual_contigs(
605605

606606
# Test with region.
607607
seq = api.genome_sequence(region=chrom)
608-
start, stop = sorted(np.random.randint(low=1, high=len(seq), size=2))
608+
start, stop = sorted(map(int, np.random.randint(low=1, high=len(seq), size=2)))
609609
region = f"{chrom}:{start:,}-{stop:,}"
610610

611611
# Standard checks.

tests/anoph/test_snp_frq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def test_snp_effects(fixture, api: AnophelesSnpFrequencyAnalysis):
153153

154154
# Check some values.
155155
assert np.all(df["contig"] == transcript["contig"])
156-
position = df["position"].values
156+
position = df["position"].to_numpy()
157157
assert np.all(position >= transcript["start"])
158158
assert np.all(position <= transcript["end"])
159159
assert np.all(position[1:] >= position[:-1]) # type: ignore

0 commit comments

Comments
 (0)