-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #572 from kif/571_debian_report
Issues spotted by debian report
- Loading branch information
Showing
9 changed files
with
62 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ | |
__contact__ = "[email protected]" | ||
__license__ = "MIT" | ||
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" | ||
__version__ = "17/10/2012" | ||
__date__ = "30/05/2024" | ||
|
||
import io | ||
from .fabioimage import FabioImage | ||
|
@@ -84,17 +84,21 @@ def read(self, fname, dim1, dim2, offset=0, bytecode="int32", endian="<"): | |
:param int dim2: image dimensions (Slow index) | ||
:param int offset: starting position of the data-block. If negative, starts at the end. | ||
:param bytecode: can be "int8","int16","int32","int64","uint8","uint16","uint32","uint64","float32","float64",... | ||
:param endian: among short or long endian ("<" or ">") | ||
:param endian: among litte or big endian ("<" or ">") | ||
""" | ||
assert endian in ('<', '>', '=') | ||
bytecode = numpy.dtype(bytecode) | ||
if not bytecode.str.startswith(endian): | ||
bytecode = numpy.dtype(endian + bytecode.str[1:]) | ||
self.filename = fname | ||
self._shape = dim2, dim1 | ||
self._bytecode = bytecode | ||
with open(self.filename, "rb") as f: | ||
with open(self.filename, "rb") as f: | ||
dims = [dim2, dim1] | ||
bpp = numpy.dtype(bytecode).itemsize | ||
size = dims[0] * dims[1] * bpp | ||
|
||
if offset >= 0: | ||
f.seek(offset) | ||
else: | ||
|
@@ -107,8 +111,6 @@ def read(self, fname, dim1, dim2, offset=0, bytecode="int32", endian="<"): | |
logger.error('Uncommon error encountered when reading file') | ||
rawData = f.read(size) | ||
data = numpy.frombuffer(rawData, bytecode).copy().reshape(tuple(dims)) | ||
if self.swap_needed(endian): | ||
data.byteswap(True) | ||
self.data = data | ||
self._shape = None | ||
return self | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
__author__ = ["Florian Plaswig", "Jérôme Kieffer"] | ||
__contact__ = "[email protected]" | ||
__license__ = "MIT" | ||
__date__ = "13/11/2020" | ||
__date__ = "30/05/2024" | ||
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" | ||
|
||
import logging | ||
|
@@ -79,7 +79,7 @@ def compress(frame): | |
if numpy.little_endian: | ||
buffer.write(row_start.tobytes()) | ||
else: | ||
buffer.write(row_start.byteswap.tobytes()) | ||
buffer.write(row_start.byteswap().tobytes()) | ||
|
||
return data_size + buffer.getvalue() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ | |
__contact__ = "[email protected]" | ||
__license__ = "MIT" | ||
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" | ||
__date__ = "03/04/2020" | ||
__date__ = "30/05/2024" | ||
|
||
import numpy | ||
import os | ||
|
@@ -71,7 +71,7 @@ def _readheader(self, infile): | |
infile.seek(0) | ||
self.header = self.check_header() | ||
byt = infile.read(4) | ||
framesize = numpy.frombuffer(byt, numpy.int32) | ||
framesize = numpy.frombuffer(byt, numpy.dtype("<i4")) | ||
if framesize * 2 == self._FRAME_SIZE - self._MAGIC_SIZE: | ||
self.header['framesize'] = framesize | ||
self.header['width'] = self._IMAGE_WIDTH | ||
|
@@ -123,7 +123,7 @@ def _readdata(self, filepointer, img_num): | |
imgstart = self.header['offset'] + img_num * self._FRAME_SIZE | ||
filepointer.seek(imgstart, 0) | ||
data = numpy.frombuffer(filepointer.read(self._IMAGE_SIZE), | ||
numpy.uint16).copy() | ||
numpy.dtype("<u2")).copy() | ||
data.shape = self.header['height'], self.header['width'] | ||
return data | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters