Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
deprecated get_original_spans
Browse files Browse the repository at this point in the history
  • Loading branch information
tamuhey committed Feb 1, 2021
1 parent e40a4d4 commit 0684a5f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
11 changes: 1 addition & 10 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(clippy::deprecated)]
use pyo3::prelude::*;
use tokenizations::{get_alignments, get_charmap, get_original_spans, Alignment, CharMap};
use tokenizations::{get_alignments, get_charmap, Alignment, CharMap};

#[pymodule]
fn tokenizations(_py: Python, m: &PyModule) -> PyResult<()> {
Expand All @@ -20,14 +20,5 @@ fn tokenizations(_py: Python, m: &PyModule) -> PyResult<()> {
Ok(get_charmap(a, b))
}

#[pyfn(m, "get_original_spans")]
pub fn get_original_spans_py(
_py: Python,
tokens: Vec<&str>,
original_text: &str,
) -> PyResult<Vec<Option<(usize, usize)>>> {
Ok(get_original_spans(&tokens, original_text))
}

Ok(())
}
3 changes: 1 addition & 2 deletions python/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,5 @@ def test_warn_get_original_spans():
reason="deprecation error check",
)
def test_error_get_original_spans():
with pytest.raises(Exception):
with pytest.raises(ValueError):
get_original_spans([], "")

7 changes: 2 additions & 5 deletions python/tokenizations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
from .tokenizations import (
get_alignments,
get_charmap,
get_original_spans as _get_original_spans,
__version__,
)


def get_original_spans(tokens, original_text):
warnings.warn(
"get_original_spans is deprecated, use `textspan.get_original_spans` instead.",
DeprecationWarning,
raise ValueError(
f"{get_original_spans.__name__} was deprecated. Please use `textspan.get_original_spans` instead."
)
return _get_original_spans(tokens, original_text)


__all__ = ["get_charmap", "get_alignments", "get_original_spans", "__version__"]

0 comments on commit 0684a5f

Please sign in to comment.