feat: to_numpy matching uproot, view parameter #498
                
     Merged
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
This closes #413, with a proposal I made in scikit-hep/uproot3#511 - we match uproot4 by default, returning normal NumPy histogram output from
to_numpy()on all storages. If the full view is required, amode="view"can be passed. In boost-histogram 1.0, this will be type checked by MyPy. An expression like this:will no longer crash if
his not backed by a simple storage. Of course, since mplhep supports PlottableProtocol now, there's no need to callto_numpy, but other classic interfaces out of our control still use this. Including Uproot3 writing.I've also added clarification to the docstring that
to_numpyis not a replacement for callingh.axes.edges();to_numpyreturns the actual NumPy edges, not the boost-histogram ones, which differ on the upper edge. If you were to refill the histogram usingnp.histogram, this would produce identical results if you use the edges returned byto_numpy, but not if you use the edges returned boost-histogram style.