Skip to content

Commit

Permalink
Remove Datablock (#570)
Browse files Browse the repository at this point in the history
Datablock has been deprecated for several years now. The dxtbx.datablock
module has been left in as an alias to the functionality now moved to
dxtbx.experiment_list, but will raise a deprecation warning pointing to
the new place.

Co-authored-by: Aaron Brewster <[email protected]>
Co-authored-by: David Waterman <[email protected]>
Co-authored-by: Nicholas Devenish <[email protected]>
  • Loading branch information
4 people authored Aug 17, 2023
1 parent 831061f commit 6185cc3
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 1,195 deletions.
1 change: 1 addition & 0 deletions newsfragments/504.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dxtbx: remove legacy datablock object (obsolete for several years)
1 change: 0 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ addopts = -rsxX
filterwarnings =
ignore:the matrix subclass is not the recommended way:PendingDeprecationWarning
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
Expand Down
10 changes: 6 additions & 4 deletions src/dxtbx/command_line/display_parallax_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
from scitbx.array_family import flex

import dxtbx.util
from dxtbx.datablock import DataBlockFactory
from dxtbx.model import ParallaxCorrectedPxMmStrategy
from dxtbx.model.experiment_list import ExperimentListFactory


def run(args=None):
dxtbx.util.encode_output_as_utf8()
datablocks = DataBlockFactory.from_args(args or sys.argv[1:])
assert len(datablocks) == 1
detectors = datablocks[0].unique_detectors()
experiments = ExperimentListFactory.from_args(
args or sys.argv[1:], check_format=False
)
assert len(experiments) == 1
detectors = experiments.detectors()
assert len(detectors) == 1
detector = detectors[0]
assert len(detector) == 1
Expand Down
19 changes: 7 additions & 12 deletions src/dxtbx/command_line/plot_detector_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
from scitbx.matrix import col

import dxtbx.util
from dxtbx.datablock import DataBlockFactory
from dxtbx.model.detector_helpers import get_detector_projection_2d_axes
from dxtbx.model.experiment_list import ExperimentListFactory

usage = """Plot dxtbx detector models. Provide multiple json files if desired
Example: dxtbx.plot_detector_models datablock1.json datablock2.json
Example: dxtbx.plot_detector_models experiments1.json experiments2.json
"""


Expand Down Expand Up @@ -181,16 +180,12 @@ def run(args=None):

# read the data and get the detector models
try:
datablocks = DataBlockFactory.from_json_file(file_name, check_format=False)
detectors = sum((db.unique_detectors() for db in datablocks), [])
except Exception:
try:
experiments = ExperimentListFactory.from_json_file(
file_name, check_format=False
)
except ValueError:
experiments = ExperimentListFactory.from_filenames([file_name])
detectors = experiments.detectors()
experiments = ExperimentListFactory.from_json_file(
file_name, check_format=False
)
except ValueError:
experiments = ExperimentListFactory.from_filenames([file_name])
detectors = experiments.detectors()
if not params.plot_all_detectors:
detectors = detectors[0:1]
for detector in detectors:
Expand Down
Loading

0 comments on commit 6185cc3

Please sign in to comment.