Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure tests: since_last, unique_timestamps, tick, join, fft, begin, end #295

Merged
merged 8 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 76 additions & 12 deletions temporian/core/operators/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,52 @@ package(
# =====

py_test(
name = "join_test",
srcs = ["join_test.py"],
name = "test_add_index",
srcs = ["test_add_index.py"],
srcs_version = "PY3",
deps = [
# already_there/absl/testing:absltest
"//temporian/core/data:dtype",
"//temporian/core/data:node",
"//temporian/core/operators:join",
"//temporian/implementation/numpy/data:io",
"//temporian/test:utils",
],
)

py_test(
name = "fft_test",
srcs = ["fft_test.py"],
name = "test_begin",
srcs = ["test_begin.py"],
srcs_version = "PY3",
deps = [
# already_there/absl/testing:absltest
"//temporian/core/data:dtype",
"//temporian/core/data:node",
"//temporian/core/operators:fast_fourier_transform",
"//temporian/implementation/numpy/data:io",
"//temporian/test:utils",
],
)

py_test(
name = "test_add_index",
srcs = ["test_add_index.py"],
name = "test_drop_index",
srcs = ["test_drop_index.py"],
srcs_version = "PY3",
deps = [
# already_there/absl/testing:absltest
"//temporian/implementation/numpy/data:io",
"//temporian/test:utils",
],
)

py_test(
name = "test_end",
srcs = ["test_end.py"],
srcs_version = "PY3",
deps = [
# already_there/absl/testing:absltest
"//temporian/implementation/numpy/data:io",
"//temporian/test:utils",
],
)

py_test(
name = "test_fast_fourier_transform",
srcs = ["test_fast_fourier_transform.py"],
srcs_version = "PY3",
deps = [
# already_there/absl/testing:absltest
Expand Down Expand Up @@ -63,6 +83,17 @@ py_test(
],
)

py_test(
name = "test_join",
srcs = ["test_join.py"],
srcs_version = "PY3",
deps = [
# already_there/absl/testing:absltest
"//temporian/implementation/numpy/data:io",
"//temporian/test:utils",
],
)

py_test(
name = "test_lag",
srcs = ["test_lag.py"],
Expand Down Expand Up @@ -162,6 +193,39 @@ py_test(
],
)

py_test(
name = "test_since_last",
srcs = ["test_since_last.py"],
srcs_version = "PY3",
deps = [
# already_there/absl/testing:absltest
"//temporian/implementation/numpy/data:io",
"//temporian/test:utils",
],
)

py_test(
name = "test_tick",
srcs = ["test_tick.py"],
srcs_version = "PY3",
deps = [
# already_there/absl/testing:absltest
"//temporian/implementation/numpy/data:io",
"//temporian/test:utils",
],
)

py_test(
name = "test_unique_timestamps",
srcs = ["test_unique_timestamps.py"],
srcs_version = "PY3",
deps = [
# already_there/absl/testing:absltest
"//temporian/implementation/numpy/data:io",
"//temporian/test:utils",
],
)

py_test(
name = "test_until_next",
srcs = ["test_until_next.py"],
Expand Down
63 changes: 0 additions & 63 deletions temporian/core/operators/test/fft_test.py

This file was deleted.

72 changes: 0 additions & 72 deletions temporian/core/operators/test/join_test.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.


from absl.testing import absltest
from absl.testing.parameterized import TestCase

from temporian.core.operators.end import EndOperator
from temporian.implementation.numpy.data.io import event_set
from temporian.implementation.numpy.operators.end import (
EndNumpyImplementation,
)

from temporian.test.utils import assertOperatorResult

class EndOperatorTest(absltest.TestCase):
def setUp(self):
pass

def test_base(self):
class BeginTest(TestCase):
def test_basic(self):
evset = event_set(
timestamps=[1, 2, 3, 4],
features={
"a": [5, 6, 7, 8],
"b": ["A", "A", "B", "B"],
},
features={"a": [5, 6, 7, 8], "b": ["A", "A", "B", "B"]},
indexes=["b"],
)
node = evset.node()

expected_output = event_set(
timestamps=[2, 4],
features={"b": ["A", "B"]},
indexes=["b"],
)
result = evset.begin()

# Run op
op = EndOperator(input=node)
instance = EndNumpyImplementation(op)
output = instance.call(input=evset)["output"]
expected = event_set(
timestamps=[1, 3], features={"b": ["A", "B"]}, indexes=["b"]
)

self.assertEqual(output, expected_output)
assertOperatorResult(self, result, expected, check_sampling=False)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.


from absl.testing import absltest
from absl.testing.parameterized import TestCase

from temporian.core.operators.begin import BeginOperator
from temporian.implementation.numpy.data.io import event_set
from temporian.implementation.numpy.operators.begin import (
BeginNumpyImplementation,
)

from temporian.test.utils import assertOperatorResult

class BeginOperatorTest(absltest.TestCase):
def setUp(self):
pass

def test_base(self):
class EndTest(TestCase):
def test_basic(self):
evset = event_set(
timestamps=[1, 2, 3, 4],
features={
"a": [5, 6, 7, 8],
"b": ["A", "A", "B", "B"],
},
features={"a": [5, 6, 7, 8], "b": ["A", "A", "B", "B"]},
indexes=["b"],
)
node = evset.node()

expected_output = event_set(
timestamps=[1, 3],
features={"b": ["A", "B"]},
indexes=["b"],
)
result = evset.end()

# Run op
op = BeginOperator(input=node)
instance = BeginNumpyImplementation(op)
output = instance.call(input=evset)["output"]
expected = event_set(
timestamps=[2, 4], features={"b": ["A", "B"]}, indexes=["b"]
)

self.assertEqual(output, expected_output)
assertOperatorResult(self, result, expected, check_sampling=False)


if __name__ == "__main__":
Expand Down
Loading