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

DIALS 3.15.2 #185

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
700bb2e
Bump version: 3.15.dev → 3.16.dev
DiamondLightSource-build-server Jun 13, 2023
e7b27b4
Remove dxtbx procrunner dependency (#640)
rjgildea Jun 16, 2023
f5e835c
Fix for nxmx import overwritten by local variable (#641)
rjgildea Jun 27, 2023
133ca8e
MNT: Skip tests removed from DLS filesystem
ndevenish Jun 27, 2023
6c6d665
DIALS 3.15.1 Changelog
DiamondLightSource-build-server Jun 29, 2023
71d4ec0
Use importlib instead of pkg_resources (#643)
ndevenish Jun 29, 2023
1625cfa
Drop Python 3.8 support (#642)
rjgildea Jun 30, 2023
930be09
Easier override of panel geometry (#644)
dagewa Jul 25, 2023
436a1b6
Flumpy: Don't allow converting 1D vectors to vec2/3 (#648)
ndevenish Jul 25, 2023
180fac8
FormatROD (#645)
dagewa Jul 26, 2023
e9b88d2
Check Registry against refl/expt files (#650)
ndevenish Jul 26, 2023
69169ff
Make Imageset slices consistently index from 0
dagewa Jul 26, 2023
0a068b5
MNT: Update CMake modules path relative to script
ndevenish Jul 27, 2023
64bcb32
Fixes for EMBL beamlines at PETRA (#626)
christianbecke Jul 31, 2023
ef5f9ab
Add polychromatic beam (#621)
toastisme Aug 2, 2023
5c27616
FormatROD - Multi-axis goniometer, faster decompression (#653)
dagewa Aug 3, 2023
4783b2c
Add probe type to the Beam model (#647)
dagewa Aug 4, 2023
d516f20
Fix bit depth for Eiger / NXmx for i19-2 (#652)
graeme-winter Aug 8, 2023
39c4923
ESRF ID23-2 support (#651)
graeme-winter Aug 10, 2023
206c7cb
FormatCBFMiniEigerChessID7B2 (#649)
dagewa Aug 10, 2023
3bc6e67
NXmx: handle multidimensional arrays (#612)
phyy-nx Aug 11, 2023
5e079c7
Update CI prebuilt version of CCTBX (#655)
ndevenish Aug 11, 2023
eda7169
Clean Clutter
DiamondLightSource-build-server Aug 13, 2023
f464b57
dxtbx 3.16.0 Changelog
DiamondLightSource-build-server Aug 14, 2023
bc8b6d1
Ignore trusted-range in dxtbx.average test
ndevenish Jan 23, 2023
a13143c
Bump version: 3.16.dev → 3.16.0
DiamondLightSource-build-server Aug 14, 2023
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 .azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ stages:
steps:
- checkout: none

# Use Python >=3.8 for syntax validation
# Use Python >=3.9 for syntax validation
- task: UsePythonVersion@0
displayName: Set up python
inputs:
versionSpec: 3.8
versionSpec: 3.9

# Run syntax validation on a shallow clone
- bash: |
Expand Down Expand Up @@ -78,7 +78,7 @@ stages:
vmImage: ubuntu-20.04
timeoutInMinutes: 60
variables:
PYTHON_VERSION: 3.8
PYTHON_VERSION: 3.9
steps:
- template: unix-build.yml

Expand All @@ -88,10 +88,10 @@ stages:
vmImage: ubuntu-20.04
strategy:
matrix:
python38:
PYTHON_VERSION: 3.8
python39:
PYTHON_VERSION: 3.9
python311:
PYTHON_VERSION: 3.11
timeoutInMinutes: 60
steps:
- template: unix-build.yml
Expand All @@ -101,10 +101,10 @@ stages:
vmImage: macOS-latest
strategy:
matrix:
python38:
PYTHON_VERSION: 3.8
python39:
PYTHON_VERSION: 3.9
python311:
PYTHON_VERSION: 3.11
timeoutInMinutes: 60
steps:
- template: unix-build.yml
Expand All @@ -114,8 +114,10 @@ stages:
vmImage: windows-2019
strategy:
matrix:
python38:
PYTHON_VERSION: 3.8
python39:
PYTHON_VERSION: 3.9
python311:
PYTHON_VERSION: 3.11
timeoutInMinutes: 20
steps:
- template: windows-build.yml
Expand Down
2 changes: 1 addition & 1 deletion .azure-pipelines/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ def run():
"--python",
help="Install this minor version of Python (default: %(default)s)",
default="3.9",
choices=("3.8", "3.9", "3.10"),
choices=("3.9", "3.10", "3.11"),
)
parser.add_argument(
"--branch",
Expand Down
3 changes: 1 addition & 2 deletions .azure-pipelines/ci-conda-env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ conda-forge::boost
conda-forge::boost-cpp
conda-forge::bzip2
conda-forge::c-compiler<1.5
conda-forge::cctbx-base==2023.5
conda-forge::cctbx-base==2023.7
conda-forge::conda
conda-forge::cxx-compiler<1.5
conda-forge::python-dateutil
Expand All @@ -22,7 +22,6 @@ conda-forge::orderedset
conda-forge::pillow>=5.4.1
conda-forge::pint
conda-forge::pip
conda-forge::procrunner
conda-forge::psutil
conda-forge::pyrtf
conda-forge::pybind11
Expand Down
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.15.dev
current_version = 3.16.0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<release>[a-z]+)?(?P<patch>\d+)?
Expand Down
39 changes: 39 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
dxtbx 3.16.0 (2023-08-14)
=========================

Features
--------

- Add new Beam class ``dxtbx.model.PolychromaticBeam``, for polychromatic/multi-wavelength/wide bandpass experiments. (`#621 <https://github.com/cctbx/dxtbx/issues/621>`_)
- Formats: Reflect move of Eiger detector from PETRA P14 to P13. (`#626 <https://github.com/cctbx/dxtbx/issues/626>`_)
- The ``model.Beam`` object now has a ``probe`` value to keep track of the type of radiation. (`#647 <https://github.com/cctbx/dxtbx/issues/647>`_)
- Formats: CBFMini support for the EIGER2 16M detector at CHESS beamline ID7B2, which has an inverted rotation axis. (`#649 <https://github.com/cctbx/dxtbx/issues/649>`_)
- Formats: Support for Eiger 9M on ESRF ID23-2, which has an undeclared vertical goniometer. (`#651 <https://github.com/cctbx/dxtbx/issues/651>`_)
- Formats: Partial support for the Rigaku Oxford Diffraction file format, including support for multi-axis goniometers and faster decompression. (`#645 <https://github.com/cctbx/dxtbx/issues/645>`_) (`#653 <https://github.com/cctbx/dxtbx/issues/653>`_)


Bugfixes
--------

- Panel geometry definitions in PHIL are merged by panel id *before* constructing panels. (`#299 <https://github.com/cctbx/dxtbx/issues/299>`_)
- ``flumpy``: Fix case where incorrect ``flex.vec2``, ``flex.vec3`` could be generated. (`#439 <https://github.com/cctbx/dxtbx/issues/439>`_)
- NXmx files with multidimensional arrays (images, modules, or both) are now handled. (`#612 <https://github.com/cctbx/dxtbx/issues/612>`_)
- Slicing of imageset objects is now consistently 0-based, including for the sliced data accessor. Previously, the data accessor had to be accessed with the original index offsets. (`#633 <https://github.com/cctbx/dxtbx/issues/633>`_)
- Formats: Add fix for Eiger / NXmx data from DLS i19-2, to correctly assign the image bit depth. (`#652 <https://github.com/cctbx/dxtbx/issues/652>`_)


Misc
----

- `#640 <https://github.com/cctbx/dxtbx/issues/640>`_, `#642 <https://github.com/cctbx/dxtbx/issues/642>`_, `#643 <https://github.com/cctbx/dxtbx/issues/643>`_, `#645 <https://github.com/cctbx/dxtbx/issues/645>`_, `#650 <https://github.com/cctbx/dxtbx/issues/650>`_, `#655 <https://github.com/cctbx/dxtbx/issues/655>`_


DIALS 3.15.1 (2023-06-29)
=========================

Bugfixes
--------

- ``dxtbx.dlsnxs2cbf``: Fix import overwritten by local variable. (`#641 <https://github.com/cctbx/dxtbx/issues/641>`_)


dxtbx 3.15.0 (2023-06-13)
=========================

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(dxtbx LANGUAGES C CXX)

# Add the included modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")

# General cmake environment configuration
include(SetDefaultBuildRelWithDebInfo) # Default builds to release with debug info
Expand Down
1 change: 0 additions & 1 deletion libtbx_config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"python_required": [
"dials-data>=2.0.30",
"pint",
"procrunner>=1.0.2",
"pytest>=4.5,<5.0",
],
}
11 changes: 3 additions & 8 deletions libtbx_refresh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import contextlib
import importlib
import inspect
import io
import os
Expand All @@ -17,11 +18,6 @@
except ModuleNotFoundError:
pass

try:
import pkg_resources
except ModuleNotFoundError:
pkg_resources = None


def _install_setup_readonly_fallback(package_name: str):
"""
Expand Down Expand Up @@ -67,9 +63,8 @@ def _install_setup_readonly_fallback(package_name: str):
if import_path not in sys.path:
sys.path.insert(0, import_path)

# ...and add to the existing pkg_resources working_set
if pkg_resources:
pkg_resources.working_set.add_entry(import_path)
# ...and make sure it is picked up by the import system
importlib.invalidate_caches()

# This is already generated by this point, but will get picked up
# on the second libtbx.refresh.
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ filterwarnings =
ignore:numpy.dtype size changed:RuntimeWarning
ignore:Datablocks are deprecated:UserWarning
ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning
ignore:`product` is deprecated as of NumPy:DeprecationWarning:h5py|numpy
junit_family = legacy
markers =
regression: dxtbx regression test
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ classifiers =
Operating System :: Microsoft :: Windows
Operating System :: POSIX :: Linux
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11

[flake8]
# Black disagrees with flake8 on a few points. Ignore those.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Static version number which is updated by bump2version
# Do not change this manually - use 'bump2version <major/minor/patch/release>'
__version_tag__ = "3.15.dev"
__version_tag__ = "3.16.0"

setup_kwargs = {
"name": "dxtbx",
Expand Down
126 changes: 126 additions & 0 deletions src/dxtbx/boost_python/compression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,129 @@ unsigned int dxtbx::boost_python::cbf_decompress(const char *packed,

return values - original;
}

inline uint32_t read_uint32_from_bytearray(const char *buf) {
// `char` can be signed or unsigned depending on the platform.
// For bit shift operations, we need unsigned values.
// If `char` on the platform is signed, converting directly to "unsigned int" can
// produce huge numbers because modulo 2^n is taken by the integral conversion
// rules. Thus, we have to explicitly cast to `unsigned char` first.
// Then the automatic integral promotion converts them to `int`.
// Note that the unsigned to signed conversion is implementation-dependent
// and might not produce the intended result if two's complement is not used.
// Fortunately, DIALS targets only two's complement.
// https://github.com/cctbx/dxtbx/issues/11#issuecomment-1657809645
// Moreover, C++20 standarized this:
// https://stackoverflow.com/questions/54947427/going-from-signed-integers-to-unsigned-integers-and-vice-versa-in-c20

return ((unsigned char)buf[0]) | (((unsigned char)buf[1]) << 8)
| (((unsigned char)buf[2]) << 16) | (((unsigned char)buf[3]) << 24);
}

inline uint16_t read_uint16_from_bytearray(const char *buf) {
return ((unsigned char)buf[0]) | ((unsigned char)buf[1] << 8);
}

void dxtbx::boost_python::rod_TY6_decompress(int *const ret,
const char *const buf_data,
const char *const buf_offsets,
const int slow,
const int fast) {
const size_t BLOCKSIZE = 8; // Codes below assume this is at most 8
const signed int SHORT_OVERFLOW = 127; // after 127 is subtracted
const signed int LONG_OVERFLOW = 128;

const size_t nblock = (fast - 1) / (BLOCKSIZE * 2);
const size_t nrest = (fast - 1) % (BLOCKSIZE * 2);

for (size_t iy = 0; iy < slow; iy++) {
size_t ipos = read_uint32_from_bytearray(buf_offsets + iy * sizeof(uint32_t));
size_t opos = fast * iy;

// Values from -127 to +126 (inclusive) are stored with an offset of 127
// as 0 to 253. 254 and 255 mark short and long overflows.
// Other values ("overflows") are represented in two's complement.

int firstpx = (unsigned char)buf_data[ipos++] - 127;
if (firstpx == LONG_OVERFLOW) {
// See comments in read_uint32_from_bytearray() about
// the safety of the unsigned to signed conversion.
firstpx = (signed int)read_uint32_from_bytearray(buf_data + ipos);
ipos += 4;
} else if (firstpx == SHORT_OVERFLOW) {
firstpx = (signed short)read_uint16_from_bytearray(buf_data + ipos);
ipos += 2;
}
ret[opos++] = firstpx;

// For every two blocks
for (int k = 0; k < nblock; k++) {
const size_t bittypes = buf_data[ipos++];
const size_t nbits[2] = {bittypes & 15, (bittypes >> 4) & 15};

// One pixel is stored using `nbit` bits.
// Although `nbit` itself is stored using 4 bits,
// only values 1 (0001b) to 8 (1000b) are allowed.
// Negative values are encoded as follows. (Not 2's complement!)
// - When nbit = 1, the pixel value is 0 or 1
// - When nbit = 2, the pixel value is -1, 0, 1, 2
// - When nbit = 3, the pixel value is -3, -2, 1, 0, 1, 2, 3, 4
// - When nbit - 8, the pixel value is -127, -126, ...,
// 127 (== // SHORT_OVERFLOW), 128 (== LONG_OVERFLOW)

// Load values
for (int i = 0; i < 2; i++) {
const size_t nbit = nbits[i];
assert(nbit >= 0 && nbit <= 8);

int zero_at = 0;
if (nbit > 1) {
zero_at = (1 << (nbit - 1)) - 1;
}

// Since nbit is at most 8, 8 * 8 (= BLOCKSIZE) = 64 bits are sufficient.
unsigned long long v = 0;
for (int j = 0; j < nbit; j++) {
// Implicit promotion is only up to 32 bits, not 64 bits so we have to be
// explicit.
v |= (long long)((unsigned char)buf_data[ipos++]) << (BLOCKSIZE * j);
}

const unsigned long long mask = (1 << nbit) - 1;
for (int j = 0; j < BLOCKSIZE; j++) {
ret[opos++] = ((v >> (nbit * j)) & mask) - zero_at;
}
}

// Apply differences. Load more values when overflown.
for (size_t i = opos - 2 * BLOCKSIZE; i < opos; i++) {
int offset = ret[i];

if (offset == LONG_OVERFLOW) {
offset = (signed int)read_uint32_from_bytearray(buf_data + ipos);
ipos += 4;
} else if (offset == SHORT_OVERFLOW) {
offset = (signed short)read_uint16_from_bytearray(buf_data + ipos);
ipos += 2;
}

ret[i] = offset + ret[i - 1];
}
}

for (int i = 0; i < nrest; i++) {
int offset = (unsigned char)buf_data[ipos++] - 127;

if (offset == LONG_OVERFLOW) {
offset = (signed int)read_uint32_from_bytearray(buf_data + ipos);
ipos += 4;
} else if (offset == SHORT_OVERFLOW) {
offset = (signed short)read_uint16_from_bytearray(buf_data + ipos);
ipos += 2;
}

ret[opos] = ret[opos - 1] + offset;
opos++;
}
}
}
6 changes: 6 additions & 0 deletions src/dxtbx/boost_python/compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
namespace dxtbx { namespace boost_python {
unsigned int cbf_decompress(const char*, std::size_t, int*, const std::size_t);
std::vector<char> cbf_compress(const int*, const std::size_t&);
// Decompress Rigaku Oxford diffractometer TY6 compression
void rod_TY6_decompress(int* const,
const char* const,
const char* const,
const int,
const int);
}} // namespace dxtbx::boost_python

#endif
21 changes: 21 additions & 0 deletions src/dxtbx/boost_python/ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,24 @@ namespace dxtbx { namespace boost_python {
return PyBytes_FromStringAndSize(&*packed.begin(), packed.size());
}

// Python entry point to decompress Rigaku Oxford Diffractometer TY6 compression
scitbx::af::flex_int uncompress_rod_TY6(const boost::python::object &data,
const boost::python::object &offsets,
const int &slow,
const int &fast) {
// Cannot I extract const char* directly?
std::string str_data = boost::python::extract<std::string>(data);
std::string str_offsets = boost::python::extract<std::string>(offsets);

scitbx::af::flex_int z((scitbx::af::flex_grid<>(slow, fast)),
scitbx::af::init_functor_null<int>());

dxtbx::boost_python::rod_TY6_decompress(
z.begin(), str_data.c_str(), str_offsets.c_str(), slow, fast);

return z;
}

void init_module() {
using namespace boost::python;
def("read_uint8", read_uint8, (arg("file"), arg("count")));
Expand All @@ -206,6 +224,9 @@ namespace dxtbx { namespace boost_python {
def("is_big_endian", is_big_endian);
def("uncompress", &uncompress, (arg_("packed"), arg_("slow"), arg_("fast")));
def("compress", &compress);
def("uncompress_rod_TY6",
&uncompress_rod_TY6,
(arg_("data"), arg_("offsets"), arg_("slow"), arg_("fast")));
}

BOOST_PYTHON_MODULE(dxtbx_ext) {
Expand Down
Loading
Loading