Skip to content

Commit 2ec1026

Browse files
committed
Prefix Python objects with 'Py'.
1 parent ee98cdb commit 2ec1026

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use pyo3::prelude::*;
2020
/// queries.
2121
#[pymodinit]
2222
fn finalfrontier(_py: Python, m: &PyModule) -> PyResult<()> {
23-
m.add_class::<PythonModel>()?;
24-
m.add_class::<PythonWordSimilarity>()?;
23+
m.add_class::<PyModel>()?;
24+
m.add_class::<PyWordSimilarity>()?;
2525
Ok(())
2626
}
2727

@@ -30,7 +30,7 @@ fn finalfrontier(_py: Python, m: &PyModule) -> PyResult<()> {
3030
/// The similarity is normally a value between -1 (opposite
3131
/// vectors) and 1 (identical vectors).
3232
#[pyclass(name=WordSimilarity)]
33-
struct PythonWordSimilarity {
33+
struct PyWordSimilarity {
3434
#[prop(get)]
3535
word: String,
3636

@@ -41,7 +41,7 @@ struct PythonWordSimilarity {
4141
}
4242

4343
#[pyproto]
44-
impl PyObjectProtocol for PythonWordSimilarity {
44+
impl PyObjectProtocol for PyWordSimilarity {
4545
fn __repr__(&self) -> PyResult<String> {
4646
Ok(format!(
4747
"WordSimilarity('{}', {})",
@@ -56,13 +56,13 @@ impl PyObjectProtocol for PythonWordSimilarity {
5656

5757
/// A finalfrontier model.
5858
#[pyclass(name=Model)]
59-
struct PythonModel {
59+
struct PyModel {
6060
model: finalfrontier::Model,
6161
token: PyToken,
6262
}
6363

6464
#[pymethods]
65-
impl PythonModel {
65+
impl PyModel {
6666
/// Load a model from the given `path`.
6767
///
6868
/// When the `mmap` argument is `True`, the embedding matrix is
@@ -79,7 +79,7 @@ impl PythonModel {
7979
}
8080
};
8181

82-
obj.init(|token| PythonModel { model, token })
82+
obj.init(|token| PyModel { model, token })
8383
}
8484

8585
/// Perform an anology query.
@@ -103,7 +103,7 @@ impl PythonModel {
103103
let mut r = Vec::with_capacity(results.len());
104104
for ws in results {
105105
r.push(
106-
Py::new(py, |token| PythonWordSimilarity {
106+
Py::new(py, |token| PyWordSimilarity {
107107
word: ws.word.to_owned(),
108108
similarity: ws.similarity.into_inner(),
109109
token,
@@ -136,7 +136,7 @@ impl PythonModel {
136136
let mut r = Vec::with_capacity(results.len());
137137
for ws in results {
138138
r.push(
139-
Py::new(py, |token| PythonWordSimilarity {
139+
Py::new(py, |token| PyWordSimilarity {
140140
word: ws.word.to_owned(),
141141
similarity: ws.similarity.into_inner(),
142142
token,

0 commit comments

Comments
 (0)