Skip to content

Commit

Permalink
fix(modeldataset): enable init with polydata
Browse files Browse the repository at this point in the history
fix #283
  • Loading branch information
AntoineDao authored and mostaphaRoudsari committed Nov 2, 2021
1 parent 6bc4563 commit a4be5b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions honeybee_vtk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ def color_by(self, value: str):
fields_info = self.fields_info
if not value:
self._color_by = None
return
else:
assert value in fields_info, \
f'{value} is not a valid data field for this ModelDataSet. Available ' \
Expand Down
12 changes: 10 additions & 2 deletions tests/github/types_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Unit test for the types module."""

import warnings
import pytest
import vtk
from honeybee.model import Model as HBModel
from honeybee_vtk.types import PolyData, _get_data_range
from honeybee_vtk.model import Model
from honeybee_vtk.types import ModelDataSet, PolyData, _get_data_range

file_path = r'tests/assets/gridbased.hbjson'
hb_model = HBModel.from_hbjson(file_path)
Expand Down Expand Up @@ -151,3 +150,12 @@ def test_get_data_range():
# make sure when string array is used, simply data_range is returned
values = vtk.vtkStringArray()
assert _get_data_range('test', [0, 100], values) == (0, 100)


def test_model_dataset_initialization_with_polydata():
polydata = PolyData()
polydata.add_data([1, 2, 3], 'demo-data')
md = ModelDataSet('test', [polydata])

assert md.data == [polydata]
assert md._color_by is None

0 comments on commit a4be5b4

Please sign in to comment.