From 8a5e2bcda7ba83ce3a2b62c08b99733fb49cbda4 Mon Sep 17 00:00:00 2001 From: Carl Kadie Date: Tue, 2 Jul 2024 11:27:00 -0700 Subject: [PATCH] apply fix for all version of numpy and python --- Cargo.lock | 2 +- Cargo.toml | 2 +- bed_reader/_open_bed.py | 10 +++------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df759cc..410511e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -142,7 +142,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bed-reader" -version = "1.0.5-beta.2" +version = "1.0.5-beta.3" dependencies = [ "anyhow", "anyinput", diff --git a/Cargo.toml b/Cargo.toml index 51deffc..71b16a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/bed_reader/_open_bed.py b/bed_reader/_open_bed.py index 85147f8..4ab392b 100644 --- a/bed_reader/_open_bed.py +++ b/bed_reader/_open_bed.py @@ -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 @@ -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 @@ -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: