Skip to content

Commit

Permalink
FormatROD: clarified function names
Browse files Browse the repository at this point in the history
  • Loading branch information
biochem-fan committed Aug 2, 2023
1 parent 604ea58 commit 5cb88a9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/dxtbx/boost_python/compression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ inline uint16_t read_uint16_from_bytearray(const char *buf) {
return ((unsigned char)buf[0]) | ((unsigned char)buf[1] << 8);
}

void dxtbx::boost_python::TY6_decompress(int *const ret,
const char *const buf_data,
const char *const buf_offsets,
const int slow,
const int fast) {
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;
Expand Down
11 changes: 6 additions & 5 deletions src/dxtbx/boost_python/compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +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&);
void TY6_decompress(int* const,
const char* const,
const char* const,
const int,
const int);
// 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
15 changes: 8 additions & 7 deletions src/dxtbx/boost_python/ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,19 @@ namespace dxtbx { namespace boost_python {
return PyBytes_FromStringAndSize(&*packed.begin(), packed.size());
}

scitbx::af::flex_int uncompressTY6(const boost::python::object &data,
const boost::python::object &offsets,
const int &slow,
const int &fast) {
// 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::TY6_decompress(
dxtbx::boost_python::rod_TY6_decompress(
z.begin(), str_data.c_str(), str_offsets.c_str(), slow, fast);

return z;
Expand All @@ -223,8 +224,8 @@ 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("uncompressTY6",
&uncompressTY6,
def("uncompress_rod_TY6",
&uncompress_rod_TY6,
(arg_("data"), arg_("offsets"), arg_("slow"), arg_("fast")));
}

Expand Down
8 changes: 3 additions & 5 deletions src/dxtbx/format/FormatROD.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
from __future__ import annotations

__author__ = "David Waterman, Takanori Nakane"
__copyright__ = (
"Copyright 2018 United Kingdom Research and Innovation & 2022 Takanori Nakane"
)
__copyright__ = "Copyright 2018-2023 United Kingdom Research and Innovation & 2022-2023 Takanori Nakane"
__license__ = "BSD 3-clause"

import re
Expand All @@ -25,7 +23,7 @@
from scitbx.array_family import flex
from scitbx.math import r3_rotation_axis_and_angle_as_matrix

from dxtbx.ext import uncompressTY6
from dxtbx.ext import uncompress_rod_TY6
from dxtbx.format.Format import Format


Expand Down Expand Up @@ -376,7 +374,7 @@ def _get_raw_data_ty6_native(self):
linedata = f.read(lbytesincompressedfield)
offsets = f.read(4 * ny)

return uncompressTY6(linedata, offsets, ny, nx)
return uncompress_rod_TY6(linedata, offsets, ny, nx)

# Python implementation
def _get_raw_data_ty6(self):
Expand Down

0 comments on commit 5cb88a9

Please sign in to comment.