Skip to content
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

Add pytest 8.x compatibility #92

Merged
merged 1 commit into from
Feb 27, 2024
Merged
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
20 changes: 11 additions & 9 deletions lib/bx/binned_array_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Tests for `bx.binned_array`.
"""

import pytest
from numpy import (
allclose,
concatenate,
Expand All @@ -22,12 +23,9 @@
# CHUNK_SIZE_RANDOM=9456
# CHUNK_SIZE_ZEROS=8972

source = target = None


def setup():
global source
global target
@pytest.fixture(scope="module")
def source_target():
source = []
for _ in range(13):
if random() < 0.5:
Expand All @@ -43,7 +41,8 @@ def setup():
return source, target


def test_simple():
def test_simple(source_target):
source, target = source_target
# Verify
for i in range(len(source)):
assert source[i] == target[i], "No match, index: %d, source: %f, target: %f, len( source ): %d" % (
Expand All @@ -66,7 +65,8 @@ def test_simple():
)


def test_file():
def test_file(source_target):
source, target = source_target
# With a file (zlib)
target.to_file(open("/tmp/foo", "wb"))
target2 = FileBinnedArray(open("/tmp/foo", "rb"))
Expand All @@ -87,7 +87,8 @@ def test_file():
)


def test_file_lzo():
def test_file_lzo(source_target):
source, target = source_target
# With a file (lzo)
target.to_file(open("/tmp/foo3", "wb"), comp_type="lzo")
target3 = FileBinnedArray(open("/tmp/foo3", "rb"))
Expand All @@ -109,7 +110,8 @@ def test_file_lzo():
)


def test_binned_array_writer():
def test_binned_array_writer(source_target):
source, target = source_target
# Test with ba writer
o = open("/tmp/foo4", "wb")
w = BinnedArrayWriter(o, 128, comp_type="lzo")
Expand Down
Loading