- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 115
Fix broadcast_shape when Base.OneTo is defined #250
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
Conversation
        
          
                src/Compat.jl
              
                Outdated
          
        
      | end | ||
|  | ||
| if isdefined(Base, :OneTo) | ||
| broadcast_shape(x...) = Base.to_shape(broadcast_shape(x...)) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be Base.broadcast_shape because broadcast_shape isn't exported by Base.
If the thought is that people will say using Compat.broadcast_shape, then you also need to add a definition for the case when :OneTo isn't defined.
Maybe add something to the README, too?
| Did this come up in any other packages? | 
| NullableArrays | 
| Ah, sure if they also need it then I guess we can put it here. | 
        
          
                test/runtests.jl
              
                Outdated
          
        
      | @test view(a, :, 1) == a[:,1] | ||
| end | ||
|  | ||
| @test broadcast_shape([1 2; 3 4], [1,1]) == (2,2) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compat.
| 
 | 
| They were introduced in the same PR so the chances of hitting that on a bisect are small but nonzero. Which was introduced later? | 
| 
 | 
| check that both are defined I guess? | 
| Does that mean that if you happen to hit the commit where  | 
| Hm, probably, though I'm not sure what the behavior of  | 
| actually this might be backwards. Compat is usually supposed to backport the new behavior to old versions of julia, when it can. the String stuff is kind of an exception because it was especially messy to not break package api's on 0.4. | 
| It is and it isn't. The argument in favor of using  The argument against the automatic use of  Overall, this conversation does make me think that perhaps a better approach is: 
 Thanks @tkelman for your perceptive comment. | 
| @timholy I think we should avoid that the flexible indexing propagates down the tree from  | 
| For the record, I too would be happy if it stays in wrappers, and we keep  typealias I1 IndicesStartWith1          # save my poor fingers from too much typing
function foo(A::AbstractArray::I1)
    ...
endto make it really easy for people to ban arrays with weird indices, yet still support many different  | 
| I'm going to close this, as all issues that have resulted from this seem to have since been resolved anyway. | 
This provides a workaround for
broadcast_shapedifferences introduced byBase.OneToin JuliaLang/julia#17137. This is the approach used by DataArrays developed by @tkelman and @timholy.