Skip to content

Commit f4fa1db

Browse files
committed
Cleanup and fix 3.14 tests
1 parent 45e3f91 commit f4fa1db

File tree

2 files changed

+11
-71
lines changed

2 files changed

+11
-71
lines changed

.github/workflows/pytest-builds.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,23 @@ jobs:
3030
run:
3131
curl https://sh.rustup.rs -sSf | sh -s -- -y
3232

33-
- name: Install dependencies
33+
- name: Install dependencies (!= 3.14)
34+
if: ${{ matrix.python-version }} != '3.14'
3435
run: |
3536
pip install --upgrade pip
3637
pip install setuptools-rust pytest pydicom coverage pytest-cov
3738
pip install git+https://github.com/pydicom/pylibjpeg-data
3839
pip install -e .
3940
41+
- name: Install dependencies (== 3.14)
42+
if: ${{ matrix.python-version }} == '3.14'
43+
run: |
44+
pip install --upgrade pip
45+
pip install setuptools-rust pytest coverage pytest-cov
46+
pip install git+https://github.com/pydicom/pylibjpeg-data
47+
pip install git+https://github.com/pydicom/pydicom
48+
pip install -e .
49+
4050
- name: Test with pytest
4151
env:
4252
PYTHON_VERSION: ${{ matrix.python-version }}

src/lib.rs

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
use std::convert::TryFrom;
33
use std::error::Error;
44

5-
// use bitvec::prelude::*;
6-
75
use pyo3::prelude::*;
86
use pyo3::wrap_pyfunction;
97
use pyo3::types::{PyBytes, PyByteArray};
@@ -426,74 +424,6 @@ fn _decode_frame(
426424
}
427425

428426

429-
fn _decode_bit_packed_segment(
430-
src: &[u8], segment_length: usize
431-
) -> Result<Vec<u8>, Box<dyn Error>> {
432-
/*
433-
434-
The returned data is guaranteed to be no more than segment_length in size.
435-
*/
436-
let eod = src.len() - 1;
437-
let mut pos = 0;
438-
let mut header_byte: usize;
439-
let mut dst: Vec<u8> = Vec::new();
440-
let mut op_len: usize;
441-
let mut idx: usize = 0; // number of bytes decoded
442-
443-
let err_eod = Err(
444-
String::from(
445-
"The end of the data was reached before the segment was completely decoded"
446-
).into()
447-
);
448-
449-
loop {
450-
// `header_byte` is equivalent to N in the DICOM Standard
451-
// usize is at least u8
452-
header_byte = usize::from(src[pos]);
453-
pos += 1;
454-
if header_byte > 128 {
455-
// Extend by copying the next byte (-N + 1) times
456-
// however since using uint8 instead of int8 this will be
457-
// (256 - N + 1) times
458-
op_len = 257 - header_byte;
459-
460-
// Check we have enough encoded data
461-
if pos > eod { return err_eod }
462-
463-
// Check segment for excess padding
464-
if (idx + op_len) > segment_length {
465-
dst.extend(vec![src[pos]; segment_length - idx]);
466-
467-
return Ok(dst)
468-
}
469-
470-
dst.extend(vec![src[pos]; op_len]);
471-
idx += op_len;
472-
pos += 1;
473-
} else if header_byte < 128 {
474-
// Extend by literally copying the next (N + 1) bytes
475-
op_len = header_byte + 1;
476-
477-
// Check we have enough encoded data
478-
if (pos + header_byte) > eod { return err_eod }
479-
480-
// Check segment for excess padding
481-
if (idx + op_len) > segment_length {
482-
dst.extend(&src[pos..pos + segment_length - idx]);
483-
484-
return Ok(dst)
485-
}
486-
487-
dst.extend(&src[pos..pos + op_len]);
488-
pos += header_byte + 1;
489-
idx += op_len;
490-
} // header_byte == 128 is noop
491-
492-
if pos >= eod { return Ok(dst) }
493-
}
494-
}
495-
496-
497427
fn _decode_segment_into_frame(
498428
src: &[u8], dst: &mut Vec<u8>, bpp: usize, initial_offset: usize
499429
) -> Result<usize, Box<dyn Error>> {

0 commit comments

Comments
 (0)