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

Crash writing history.json from dials.refine #1923

Closed
dagewa opened this issue Nov 12, 2021 · 0 comments · Fixed by #1924
Closed

Crash writing history.json from dials.refine #1923

dagewa opened this issue Nov 12, 2021 · 0 comments · Fixed by #1924

Comments

@dagewa
Copy link
Member

dagewa commented Nov 12, 2021

$ dials.refine ../refined.{expt,refl} correlation_plot.filename=corrgram.pdf track_condition_number=True history=history.json scan_varying=False

ended with

Traceback (most recent call last):
  File "/home/fcx32934/sw/cctbx/build/../modules/dials/command_line/refine.py", line 477, in <module>
    run()
  File "/home/fcx32934/sw/cctbx/conda_base/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/home/fcx32934/sw/cctbx/build/../modules/dials/command_line/refine.py", line 473, in run
    history.to_json_file(params.output.history)
  File "/home/fcx32934/sw/cctbx/modules/dials/algorithms/refinement/engine.py", line 134, in to_json_file
    json.dump(d, f)
  File "/home/fcx32934/sw/cctbx/conda_base/lib/python3.8/json/__init__.py", line 179, in dump
    for chunk in iterable:
  File "/home/fcx32934/sw/cctbx/conda_base/lib/python3.8/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/home/fcx32934/sw/cctbx/conda_base/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/home/fcx32934/sw/cctbx/conda_base/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/home/fcx32934/sw/cctbx/conda_base/lib/python3.8/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/home/fcx32934/sw/cctbx/conda_base/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/home/fcx32934/sw/cctbx/conda_base/lib/python3.8/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/home/fcx32934/sw/cctbx/conda_base/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Please report this error to dials-support@lists.sourceforge.net: Object of type double is not JSON serializable

The issue is that the parameter_correlation is kept in the journal as flex.double, which was fine when history was output as pickle, but breaks now it is JSON. The fix is easy, but should add a test as well.

dagewa added a commit that referenced this issue Nov 12, 2021
There is no performance advantage here, so use Python types from
the start and return a list not flex.double. Fixes #1923.
ndevenish added a commit that referenced this issue Jan 17, 2022
Avoid attempt to write flex.double to JSON - use Python types from
the start and return a list not flex.double. Fixes #1923.

Additionally, add some typing from _packed_corr_mat backwards.

Co-authored-by: Nicholas Devenish <ndevenish@gmail.com>
ndevenish added a commit that referenced this issue Jan 25, 2022
Avoid attempt to write flex.double to JSON - use Python types from
the start and return a list not flex.double. Fixes #1923.

Additionally, add some typing from _packed_corr_mat backwards.

Co-authored-by: Nicholas Devenish <ndevenish@gmail.com>
DiamondLightSource-build-server added a commit that referenced this issue Jan 25, 2022
Features
--------

- It is now possible to explicitly bootstrap all supported python versions. (#1988)

Bugfixes
--------

- ``dials.refine``: Fix crash from recording of parameter correlations in ``history.json``. (#1923)
- Correct reporting of phi angle in scan-varying model plots. (#1929)
- ``dials.sequence_to_stills``: correct error in the crystal model for scans that do not start from image 1. (#1933)
- `dials.show`: only show format class if meaningful (i.e. not Format or FormatMultiImage) (#1981)

Improved Documentation
----------------------

- Update some Cosym and resolution-related PHIL descriptions. (#1969)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant