Skip to content

2317 Preserve ordering of input dict's keys in transforms #2321

Merged
wyli merged 2 commits intoProject-MONAI:devfrom
eddyleelin:2320-preserve-transform-dict-order
Jun 9, 2021
Merged

2317 Preserve ordering of input dict's keys in transforms #2321
wyli merged 2 commits intoProject-MONAI:devfrom
eddyleelin:2320-preserve-transform-dict-order

Conversation

@eddyleelin
Copy link
Copy Markdown
Contributor

@eddyleelin eddyleelin commented Jun 7, 2021

Fixes #2317 .

Description

Initializes the return list of dicts with a shallow copy of data (the input dict) in RandWeightedCropd and RandCropByPosNegLabeld.

Status

ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Jun 7, 2021

Hi @eddyleelin ,

Thanks for your quick PR.
About the DCO error, please try to sign off your commit:
https://github.com/Project-MONAI/MONAI/blob/dev/CONTRIBUTING.md#signing-your-work
Others look good to me.

Thanks.

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Jun 7, 2021

Please also update the unit test values:

======================================================================
FAIL: test_type_shape_2 (tests.test_rand_crop_by_pos_neg_labeld.TestRandCropByPosNegLabeld)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\parameterized\parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "D:\a\MONAI\MONAI\tests\test_rand_crop_by_pos_neg_labeld.py", line 91, in test_type_shape
    self.assertTupleEqual(tuple(result[0].keys()), tuple(input_data.keys()))
AssertionError: Tuples differ: ('ima[35 chars]dict', 'image_transforms', 'extra_transforms',[53 chars]ict') != ('ima[35 chars]dict')

Thanks.

wyli and others added 2 commits June 9, 2021 22:21
…pByPosNegLabeld

Added shallow copies of data dict to the return list of dicts to preserve order of data (input dict).

Signed-off-by: Eddy Lin <[email protected]>
Signed-off-by: Edward Lin <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
@wyli wyli marked this pull request as ready for review June 9, 2021 21:24
@wyli wyli enabled auto-merge (squash) June 9, 2021 21:24
@wyli wyli changed the title [WIP] Preserve ordering of input dict's keys in transforms 2317 Preserve ordering of input dict's keys in transforms Jun 9, 2021
@wyli wyli merged commit 8e56191 into Project-MONAI:dev Jun 9, 2021
@eddyleelin eddyleelin deleted the 2320-preserve-transform-dict-order branch June 9, 2021 23:33
wyli added a commit to wyli/MONAI that referenced this pull request Jun 10, 2021
…ONAI#2321)

* Merge branch dev into 2320-preserve-transform-dict-order

Signed-off-by: Wenqi Li <[email protected]>

* Preserve ordering of input data dict to RandWeightedCropd and RandCropByPosNegLabeld

Added shallow copies of data dict to the return list of dicts to preserve order of data (input dict).

Signed-off-by: Eddy Lin <[email protected]>
Signed-off-by: Edward Lin <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>

Co-authored-by: Wenqi Li <[email protected]>
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 this pull request may close these issues.

preserving order of the keys when transforming data

3 participants