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

[DNM] [InMemoryDataset redesign] Object-oriented as_subchunk_map #372

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

crusaderky
Copy link
Collaborator

@crusaderky crusaderky commented Sep 10, 2024

This is a partial PR that breaks down #370 into digestible chunks - see #370 (comment)

This PR refactors as_chunk_submap to be built on top of an abstract class, IndexChunkMapper, which is then implemented by one subclass per type of index.
This in and by itself is hardly useful, but it will become necessary when these mapper objects will be used all over the place by #370.

There are also a few extra features, which are unused for now:

  • IndexChunkMapper.chunk_submap, which refactors the existing code, can now
    • accept a range of chunks instead of a single chunk,
    • avoid shifting the sub index so that it remains relative to the whole array instead of the chunk, and
    • raise an exception if you pass to it a range of chunks that are completely omitted by the selection. This exception is never raised when called by the legacy as_subchunk_map.

These new features remain untested for now; unit tests will be added in #373.

@crusaderky crusaderky changed the title [InMemoryDataset redesign] Object-oriented as_subchunk_map [InMemoryDataset redesign] Object-oriented as_subchunk_map Sep 10, 2024
@crusaderky crusaderky changed the title [InMemoryDataset redesign] Object-oriented as_subchunk_map [InMemoryDataset redesign] Object-oriented as_subchunk_map Sep 10, 2024
@crusaderky crusaderky self-assigned this Sep 10, 2024
# This causes behaviour to change if a and b have opposite signs and you try
# debugging the module in pure python, without compiling it.
# This function blindly assumes that a and b are always the same sign.
return a // b + (a % b > 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No performance difference observed


@cython.cclass
class EverythingMapper(IndexChunkMapper):
"""Select all points along an axis [:]"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tecnically the same as SliceMapper(0, dset_size, 1, chunk_size, dset_size) but much cleaner and faster

#
# Or uncomment the -a flag above and then run:
# meson build && pushd build && meson compile && popd && firefox $(find build/ -name "*.html")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All of the above is a copy-paste from #371 - replicated here to allow for parallel review

@crusaderky crusaderky changed the title [InMemoryDataset redesign] Object-oriented as_subchunk_map [DNM] [InMemoryDataset redesign] Object-oriented as_subchunk_map Oct 3, 2024
@crusaderky crusaderky marked this pull request as draft October 3, 2024 14:28
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.

1 participant