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

py: ParticleSlice fixes #3367

Merged
merged 5 commits into from
Dec 12, 2019
Merged

Conversation

RudolfWeeber
Copy link
Contributor

  • Return correct elements if particle numbering is non-contigeous
  • Prevent slicing with negative indices due unclear outcome
  • Maintain order created by slicing, e.g.[9:0:-1]
  • Require that all particles exist when passing an explicit list of ids
  • Maintain order for explicit list of ids (system.part[[3,2,5,1]]
  • More rigorous testing

Fixes #3363

@RudolfWeeber RudolfWeeber added this to the Espresso 4.1.2 milestone Dec 8, 2019
@codecov
Copy link

codecov bot commented Dec 9, 2019

Codecov Report

Merging #3367 into python will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           python   #3367   +/-   ##
======================================
  Coverage      86%     86%           
======================================
  Files         537     537           
  Lines       25283   25283           
======================================
  Hits        21806   21806           
  Misses       3477    3477

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe5efb6...40c8b6e. Read the comment docs.

@RudolfWeeber
Copy link
Contributor Author

@KaiSzuttor, based on the offline discussion, I inserted a few comments which hopefully make things more clear

Copy link
Member

@KaiSzuttor KaiSzuttor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM besides minor comments

self.id_selection = np.array(slice_, dtype=int)
else:
raise TypeError(
"ParticleSlice must be initialized with an instance of slice or range, or with a list, tuple, or ndarray of ints, but got " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably use "some string {}".format(some_variable)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -2026,8 +2048,7 @@ Set quat and scalar dipole moment (dipm) instead.")
# Ids of the selected particles
ids = []
# Did we get a function as argument?
if len(args) == 1 and len(kwargs) == 0 and isinstance(
args[0], types.FunctionType):
if len(args) == 1 and len(kwargs) == 0 and callable(args[0]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remark: classes are callable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't find an other way to handle Cython oddities.

@RudolfWeeber RudolfWeeber force-pushed the particle_slice.py branch 2 times, most recently from 707f210 to 9ffdf6c Compare December 10, 2019 16:38
RudolfWeeber and others added 3 commits December 10, 2019 18:07
* Return correct elements if particle numbering is non-contigeous
* Prevent slicing with negative indices due unclear outcome
* Prevent slicing with True/False masks due to unclear outcome
* Maintain order created by slicing, e.g. [9:0:-1]
* Require that all particles exist when passing an explicit list of ids
* Maintain order for explicit list of ids
* More rigorous testing
* Minor related fixes in other test cases
self.id_selection = np.array(slice_, dtype=int)
else:
raise TypeError(
"ParticleSlice must be initialized with an instance of slice or range, or with a list, tuple, or ndarray of ints, but got {} of type {}".foormat((str(slice_), str(type(slice_)))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, is this raise tested?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the typo is .foormat

@RudolfWeeber
Copy link
Contributor Author

RudolfWeeber commented Dec 10, 2019 via email

@KaiSzuttor KaiSzuttor added the automerge Merge with kodiak label Dec 11, 2019
@KaiSzuttor
Copy link
Member

it seems like kodiak is missing an essential feature, namely updating PRs 😢

@fweik
Copy link
Contributor

fweik commented Dec 12, 2019

@KaiSzuttor @jngrad So, kodiak isn't up to the job?

@KaiSzuttor
Copy link
Member

yes, see chdsbd/kodiak#104

@fweik fweik added the Next label Dec 12, 2019
@kodiakhq kodiakhq bot merged commit c9feb5c into espressomd:python Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge with kodiak
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ParticleSlice forgets particles in member access
4 participants