Skip to content

Commit 6bf29c2

Browse files
committed
Update dependencies
1 parent c00f238 commit 6bf29c2

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ keywords = ["plot", "graph", "curve", "surface"]
1212
categories = ["science", "visualization", "mathematics", "graphics"]
1313

1414
[dependencies]
15-
numpy = "0.21"
16-
ndarray = "0.15.6"
15+
numpy = "0.22.1"
16+
ndarray = "0.16.1"
1717
curve-sampling = { version = "0.5", optional = true, git = "https://github.com/Chris00/rust-curve-sampling.git" }
1818
lazy_static = "1.4.0"
1919

2020
[dependencies.pyo3]
21-
version = "0.21.2"
21+
version = "0.22.5"
2222
features = ["auto-initialize"]
2323

2424
[features]
2525
default = ["curve-sampling"]
2626

2727
[dev-dependencies]
2828
doc-comment = "0.3.3"
29-
polars-core = { version = "0.38.1", features = ["fmt"] }
29+
polars-core = { version = "0.44.2", features = ["fmt"] }

examples/flower.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ use matplotlib as plt;
66

77
fn main() -> Result<(), Box<dyn std::error::Error>> {
88
let (fig, [[mut ax]]) = plt::subplots()?;
9-
let pseudacorus_sepal_length = Series::new("Pseudacorus_Sepal_Length",
9+
let pseudacorus_sepal_length = Series::new(
10+
"Pseudacorus_Sepal_Length".into(),
1011
&[6.0,6.0,5.8,6.5,5.7,6.8,6.5,6.8,7.0,6.2,6.5,6.6,7.0,7.0,7.5,7.0,
1112
6.8,6.5,6.3,6.2,6.9,6.3,6.3,7.0,6.2,6.8,6.2,6.3,5.8,5.9,6.2,6.3,
1213
6.9,7.3,7.5,6.4,6.6,6.4,6.7,6.4,6.4,6.6,6.4,6.2,6.3,7.9,6.9,6.2,
1314
5.9,6.3]);
14-
let pseudacorus_sepal_width = Series::new("Pseudacorus_Sepal_width",
15+
let pseudacorus_sepal_width = Series::new(
16+
"Pseudacorus_Sepal_width".into(),
1517
&[4.0,3.1,4.0,3.8,3.4,3.7,4.7,4.0,4.5,3.2,3.9,4.0,4.1,4.0,4.6,4.4,
1618
4.0,4.2,3.9,4.0,4.8,4.0,4.2,3.8,3.6,3.3,3.4,3.5,3.1,3.7,4.4,4.5,
1719
4.4,4.2,4.2,4.4,4.0,4.2,4.0,4.9,4.3,4.4,3.6,3.8,3.5,4.3,4.6,3.8,
1820
3.6,3.8]);
19-
let df = DataFrame::new(
20-
vec![pseudacorus_sepal_length,pseudacorus_sepal_width])?;
21+
let df = DataFrame::new(vec![
22+
Column::Series(pseudacorus_sepal_length),
23+
Column::Series(pseudacorus_sepal_width)])?;
2124
println!("df is {:?}", &df);
2225
let x_col = df.column("Pseudacorus_Sepal_Length")?.f64()?;
2326
let y_col = df.column("Pseudacorus_Sepal_width")?.f64()?;

src/lib.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ lazy_static! {
136136

137137
/// Container for most of the (sub-)plot elements: Axis, Tick,
138138
/// [`Line2D`], Text, Polygon, etc., and sets the coordinate system.
139-
#[derive(Debug, Clone)]
139+
#[derive(Debug)]
140140
pub struct Axes {
141141
ax: PyObject,
142142
}
@@ -190,28 +190,29 @@ impl Figure {
190190
) -> Result<[[Axes; C]; R], Error> {
191191
Python::with_gil(|py| {
192192
let axs = self.fig
193-
.call_method1(py, "subplots", (R, C))?;
193+
.bind(py)
194+
.call_method1("subplots", (R, C))?;
194195
let axes;
195196
if R == 1 {
196197
if C == 1 {
197-
axes = grid(|_,_| Axes { ax: axs.clone() });
198+
axes = grid(|_,_| Axes { ax: axs.clone().unbind() });
198199
} else { // C > 1
199200
let axg: &Bound<PyArray1<PyObject>> =
200-
axs.downcast_bound(py).unwrap();
201+
axs.downcast().unwrap();
201202
axes = grid(|_,c| {
202203
let ax = axg.get_owned(c).unwrap();
203204
Axes { ax } });
204205
}
205206
} else { // R > 1
206207
if C == 1 {
207208
let axg: &Bound<PyArray1<PyObject>> =
208-
axs.downcast_bound(py).unwrap();
209+
axs.downcast().unwrap();
209210
axes = grid(|r,_| {
210211
let ax = axg.get_owned(r).unwrap();
211212
Axes { ax } });
212213
} else { // C > 1
213214
let axg: &Bound<PyArray2<PyObject>> =
214-
axs.downcast_bound(py).unwrap();
215+
axs.downcast().unwrap();
215216
axes = grid(|r, c| {
216217
let ax = axg.get_owned([r, c]).unwrap();
217218
Axes { ax } });
@@ -238,8 +239,8 @@ impl Figure {
238239
}
239240

240241
/// Save the figure to a file.
241-
pub fn save(&self) -> Savefig {
242-
Savefig { fig: self.fig.clone(), dpi: None }
242+
pub fn save(&self) -> Savefig<'_> {
243+
Savefig { fig: &self.fig, dpi: None }
243244
}
244245

245246
/// Default width: 6.4, default height: 4.8
@@ -256,12 +257,12 @@ impl Figure {
256257

257258
/// Options for saving figures.
258259
#[must_use]
259-
pub struct Savefig {
260-
fig: PyObject,
260+
pub struct Savefig<'a> {
261+
fig: &'a PyObject,
261262
dpi: Option<f64>,
262263
}
263264

264-
impl Savefig {
265+
impl<'a> Savefig<'a> {
265266
pub fn dpi(&mut self, dpi: f64) -> &mut Self {
266267
if dpi > 0. {
267268
self.dpi = Some(dpi);
@@ -632,7 +633,7 @@ impl<'a> PlotOptions<'a> {
632633
}
633634
}
634635

635-
fn kwargs(&'a self, py: Python<'a>) -> Bound<PyDict> {
636+
fn kwargs(&'a self, py: Python<'a>) -> Bound<'a, PyDict> {
636637
let kwargs = PyDict::new_bound(py);
637638
if self.animated {
638639
kwargs.set_item("animated", true).unwrap()

0 commit comments

Comments
 (0)