@@ -180,6 +180,23 @@ axy = @inferred(A[Axis{:y}])
180180@test axy. val == 1 : 5
181181@test_throws ArgumentError A[Axis{:z }]
182182
183+ # indexing by value (implicitly) in a dimensional axis
184+ some_dates = DateTime (2016 , 1 , 2 , 0 ): Hour (1 ): DateTime (2016 , 1 , 2 , 2 )
185+ A1 = AxisArray (reshape (1 : 6 , 2 , 3 ), Axis {:x} (1 : 2 ), Axis {:y} (some_dates))
186+ A2 = AxisArray (reshape (1 : 6 , 2 , 3 ), Axis {:x} (1 : 2 ), Axis {:y} (collect (some_dates)))
187+ for A in (A1, A2)
188+ @test A[:, DateTime (2016 , 1 , 2 , 1 )] == [3 ; 4 ]
189+ @test A[:, DateTime (2016 , 1 , 2 , 1 ) .. DateTime (2016 , 1 , 2 , 2 )] == [3 5 ; 4 6 ]
190+ @test_throws BoundsError A[:, DateTime (2016 , 1 , 2 , 3 )]
191+ @test_throws BoundsError A[:, DateTime (2016 , 1 , 1 , 23 )]
192+ try
193+ A[:, DateTime (2016 , 1 , 2 , 3 )]
194+ @test " unreachable" === false
195+ catch err
196+ @test err == BoundsError (A. axes[2 ]. val, DateTime (2016 , 1 , 2 , 3 ))
197+ end
198+ end
199+
183200# Test for the expected exception type given repeated axes
184201A = AxisArray (rand (2 ,2 ), :x , :y )
185202@test_throws ArgumentError A[Axis {:x} (1 ), Axis {:x} (1 )]
0 commit comments