Skip to content

Commit

Permalink
apply fix for all version of numpy and python
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlKCarlK committed Jul 2, 2024
1 parent 3a0c8e2 commit 8a5e2bc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
version = "1.0.5-beta.2"
version = "1.0.5-beta.3"
name = "bed-reader"
description = "Read and write the PLINK BED format, simply and efficiently."
repository = "https://github.com/fastlmm/bed-reader"
Expand Down
10 changes: 3 additions & 7 deletions bed_reader/_open_bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import multiprocessing
import os
import re
import sys
from dataclasses import dataclass
from io import BytesIO
from itertools import repeat, takewhile
Expand Down Expand Up @@ -1815,12 +1814,7 @@ def _read_csv(filepath, delimiter=None, dtype=None, usecols=None):
col = transposed[output_index]

# work around numpy/python bug
if (
(sys.version_info.major, sys.version_info.minor) <= (3, 9)
and int(np.__version__.split(".")[0]) >= 2
and len(col) > 0
and pattern.fullmatch(col[0])
):
if len(col) > 0 and pattern.fullmatch(col[0]):
col = np.array([pattern.fullmatch(x).group(1) for x in col])

# Find the dtype for this column
Expand All @@ -1838,6 +1832,8 @@ def _convert_to_dtype(str_arr, dtype):
return str_arr

try:
if str_arr[0].startswith("np."):
raise ValueError("invalid cmk for int: 'np.'")
new_arr = str_arr.astype(dtype)
except ValueError as e:
if dtype == np.float32:
Expand Down

0 comments on commit 8a5e2bc

Please sign in to comment.