Skip to content

Commit

Permalink
fix python
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Aug 5, 2021
1 parent 965ff63 commit c032df8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions py-polars/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::series::PySeries;
use polars::chunked_array::object::PolarsObjectSafe;
use polars::frame::row::Row;
use polars::prelude::AnyValue;
use polars_core::utils::arrow::datatypes::ArrowNativeType;
use polars_core::utils::arrow::types::NativeType;
use pyo3::basic::CompareOp;
use pyo3::conversion::{FromPyObject, IntoPy};
use pyo3::prelude::*;
Expand Down Expand Up @@ -270,7 +270,7 @@ impl Default for ObjectValue {
}
}

impl<'a, T: ArrowNativeType + FromPyObject<'a>> FromPyObject<'a> for Wrap<AlignedVec<T>> {
impl<'a, T: NativeType + FromPyObject<'a>> FromPyObject<'a> for Wrap<AlignedVec<T>> {
fn extract(obj: &'a PyAny) -> PyResult<Self> {
let seq = <PySequence as PyTryFrom>::try_from(obj)?;
let mut v = AlignedVec::with_capacity(seq.len().unwrap_or(0) as usize);
Expand Down
4 changes: 2 additions & 2 deletions py-polars/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ impl PyDataFrame {

pub fn take(&self, indices: Wrap<AlignedVec<u32>>) -> PyResult<Self> {
let indices = indices.0;
let indices = indices.into_primitive_array::<UInt32Type>(None);
let df = self.df.take(&indices.into()).map_err(PyPolarsEr::from)?;
let indices = UInt32Chunked::new_from_aligned_vec("", indices);
let df = self.df.take(&indices).map_err(PyPolarsEr::from)?;
Ok(PyDataFrame::new(df))
}

Expand Down
7 changes: 2 additions & 5 deletions py-polars/src/series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,9 @@ impl PySeries {

pub fn take(&self, indices: Wrap<AlignedVec<u32>>) -> PyResult<Self> {
let indices = indices.0;
let indices = indices.into_primitive_array::<UInt32Type>(None);
let indices = UInt32Chunked::new_from_aligned_vec("", indices);

let take = self
.series
.take(&indices.into())
.map_err(PyPolarsEr::from)?;
let take = self.series.take(&indices).map_err(PyPolarsEr::from)?;
Ok(PySeries::new(take))
}

Expand Down

0 comments on commit c032df8

Please sign in to comment.