Skip to content

Commit

Permalink
Richcomp may be implemented by pyo3 v 0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherRabotin committed Nov 17, 2023
1 parent 3235e59 commit 3857594
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter -F python
sccache: 'true'
manylinux: auto
before-script-linux: |
sudo apt-get update
sudo apt-get install -y libclang-dev
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -74,7 +77,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
Expand Down Expand Up @@ -105,7 +108,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand Down
12 changes: 0 additions & 12 deletions src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,18 +729,6 @@ impl Duration {
*self == other
}

#[cfg(feature = "python")]
fn __richcmp__(&self, other: Self, op: CompareOp) -> bool {
match op {
CompareOp::Lt => *self < other,
CompareOp::Le => *self <= other,
CompareOp::Eq => *self == other,
CompareOp::Ne => *self != other,
CompareOp::Gt => *self > other,
CompareOp::Ge => *self >= other,
}
}

// Python constructors

#[cfg(feature = "python")]
Expand Down
13 changes: 12 additions & 1 deletion tests/python/test_epoch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hifitime import Epoch, TimeSeries, Unit
from hifitime import Epoch, TimeSeries, Unit, Duration
from datetime import datetime


Expand Down Expand Up @@ -44,3 +44,14 @@ def test_time_series():
print(f"#{num}:\t{epoch}")

assert num == 10

def test_duration_eq():
"""
Checks that Duration comparisons work
"""

assert Unit.Second * 0.0 == Duration("0 ns")
assert Unit.Second * 1.0 >= Duration("0 ns")
assert Unit.Second * 1.0 > Duration("0 ns")
assert Duration("0 ns") <= Unit.Second * 1.0
assert Duration("0 ns") < Unit.Second * 1.0

0 comments on commit 3857594

Please sign in to comment.