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

Add internal constructors from_data_ptr(...).with_strides_dim(...) and use everywhere #908

Merged
merged 3 commits into from
Feb 4, 2021

Commits on Feb 3, 2021

  1. FEAT: Add internal array builder methods from_data_ptr and with_strid…

    …es_dim
    
    These methods will be used instead of the ArrayBase struct constructor
    expression.
    bluss committed Feb 3, 2021
    Configuration menu
    Copy the full SHA
    50419d3 View commit details
    Browse the repository at this point in the history
  2. FIX: Use array builder from_data_ptr(..).with_strides_dim() where pos…

    …sible
    
    This avoids using the naked ArrayBase { .. } and similar struct
    constructors, which should make it easier for us to change
    representation in the future if needed.
    
    The constructor methods are unsafe since they rely on the caller to
    assert certain invariants; this means that this change increases the
    number of `unsafe` code blocks in ndarray, but that's only correct since
    every ArrayBase construction is safety-critical w.r.t the validity of
    the pointer, dimensions and strides taken together.
    
    The resulting code is often easier to read - especially when we are only
    updating the strides and dimensions of an existing array or view.
    
    The .with_strides_dim() method requires the Dimension trait so that
    appropriate debug assertions can be added in this method if desired.
    This precludes us from using this method in the `Clone` impl, but that's
    just a minor flaw and the only exception.
    bluss committed Feb 3, 2021
    Configuration menu
    Copy the full SHA
    bb6c4ab View commit details
    Browse the repository at this point in the history
  3. FIX: Add debug assertion in with_strides_dim

    Co-authored-by: Jim Turner <github@turner.link>
    bluss and jturner314 committed Feb 3, 2021
    Configuration menu
    Copy the full SHA
    0d4272f View commit details
    Browse the repository at this point in the history