def test_query_unsorted_datetime_index_raises(self): index = PandasIndex(pd.to_datetime(["2001", "2000", "2002"]), "x") with pytest.raises(KeyError): # pandas will try to convert this into an array indexer. We should # raise instead, so we can be sure the result of indexing with a # slice is always a view. index.query({"x": slice("2001", "2002")})
def test_query_datetime(self): index = PandasIndex( pd.to_datetime(["2000-01-01", "2001-01-01", "2002-01-01"]), "x") actual = index.query({"x": "2001-01-01"}) expected = (1, None) assert actual == expected actual = index.query({"x": index.to_pandas_index().to_numpy()[1]}) assert actual == expected
def test_query(self): # TODO: add tests that aren't just for edge cases index = PandasIndex(pd.Index([1, 2, 3]), "x") with pytest.raises(KeyError, match=r"not all values found"): index.query({"x": [0]}) with pytest.raises(KeyError): index.query({"x": 0}) with pytest.raises(ValueError, match=r"does not have a MultiIndex"): index.query({"x": {"one": 0}})