Skip to content

Commit

Permalink
size test for equality (#176)
Browse files Browse the repository at this point in the history
* size test for equality
  • Loading branch information
ddkohler authored Jan 25, 2024
1 parent 964756f commit 080026f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Fixed
- Inserted WrightTools import into _map and _offset
- Tune equality handles tunes of unequal size

## [0.4.5]

Expand Down
2 changes: 2 additions & 0 deletions attune/_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def __len__(self):
return len(self.independent)

def __eq__(self, other):
if self.independent.size != other.independent.size:
return False
if not np.allclose(self.independent, other.independent):
return False
if not np.allclose(self(self.independent), other(other.independent)):
Expand Down
16 changes: 16 additions & 0 deletions tests/tune.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import attune
import numpy as np

import pytest


def test_equality():
x1 = np.linspace(0, 1, 5)
y1 = np.linspace(3, 5, 5)
t1 = attune.Tune(x1, y1)
t2 = attune.Tune(x1, y1 + 0.1)
t3 = attune.Tune(x1[:-1], y1[:-1])

assert t1 == t1
assert t1 != t2
assert t1 != t3

0 comments on commit 080026f

Please sign in to comment.