Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Kuchaiev <okuchaiev@nvidia.com>
  • Loading branch information
okuchaiev committed Feb 19, 2020
1 parent 1ac0072 commit 34ce365
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions tests/core/test_neural_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
AcousticEncodedRepresentation,
AudioSignal,
AxisKind,
AxisKindAbstract,
AxisType,
ChannelType,
ElementType,
MelSpectrogramType,
MFCCSpectrogramType,
NeuralPortNmTensorMismatchError,
NeuralType,
NeuralTypeComparisonResult,
SpectrogramType,
VoidType,
ElementType,
AxisKindAbstract
)
from tests.common_setup import NeMoUnitTest

Expand Down Expand Up @@ -193,14 +193,21 @@ def test_struct(self):
class BoundingBox(ElementType):
def __str__(self):
return "bounding box from detection model"

def fields(self):
return ("X", "Y", "W", "H")

# ALSO ADD new, user-defined, axis kind
class AxisKind2(AxisKindAbstract):
Image = 0
T1 = NeuralType(elements_type=BoundingBox(),
axes=(AxisType(kind=AxisKind.Batch, size=None, is_list=True),
AxisType(kind=AxisKind2.Image, size=None, is_list=True)))

T1 = NeuralType(
elements_type=BoundingBox(),
axes=(
AxisType(kind=AxisKind.Batch, size=None, is_list=True),
AxisType(kind=AxisKind2.Image, size=None, is_list=True),
),
)

class BadBoundingBox(ElementType):
def __str__(self):
Expand All @@ -209,7 +216,11 @@ def __str__(self):
def fields(self):
return ("X", "Y", "H")

T2 = NeuralType(elements_type=BadBoundingBox(),
axes=(AxisType(kind=AxisKind.Batch, size=None, is_list=True),
AxisType(kind=AxisKind2.Image, size=None, is_list=True)))
self.assertEqual(T2.compare(T1), NeuralTypeComparisonResult.INCOMPATIBLE)
T2 = NeuralType(
elements_type=BadBoundingBox(),
axes=(
AxisType(kind=AxisKind.Batch, size=None, is_list=True),
AxisType(kind=AxisKind2.Image, size=None, is_list=True),
),
)
self.assertEqual(T2.compare(T1), NeuralTypeComparisonResult.INCOMPATIBLE)

0 comments on commit 34ce365

Please sign in to comment.