Skip to content
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
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Release 1.2.4
=========================================

* **BUGFIX:** Fixed ``.from_array()`` de-serialization to support propagation of string-type ``x`` values to ``name``(#67).

------------------

Release 1.2.3
=========================================

Expand Down
2 changes: 1 addition & 1 deletion highcharts_core/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.3'
__version__ = '1.2.4'
3 changes: 3 additions & 0 deletions highcharts_core/options/series/data/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,10 @@ def from_array(cls, value):
raise errors.HighchartsValueError(f'data expects either a 4D or 3D '
f'collection. Collection received '
f'had {len(item)} dimensions.')

as_obj = cls.from_dict(as_dict)
if checkers.is_string(as_obj.x):
as_obj.name = as_obj.x
else:
raise errors.HighchartsValueError(f'each data point supplied must either '
f'be a WindBarb Data Point or be '
Expand Down
2 changes: 2 additions & 0 deletions highcharts_core/options/series/data/boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ def from_array(cls, value):
f'had {len(item)} dimensions.')

as_obj = cls.from_dict(as_dict)
if checkers.is_string(as_obj.x):
as_obj.name = as_obj.x
else:
raise errors.HighchartsValueError(f'each data point supplied must either '
f'be a BoxPlot Data Point or be '
Expand Down
4 changes: 3 additions & 1 deletion highcharts_core/options/series/data/bullet.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ def from_array(cls, value):
raise errors.HighchartsValueError(f'data expects either a 3D or 2D '
f'collection. Collection received '
f'had {len(item)} dimensions.')

as_obj = cls.from_dict(as_dict)
if checkers.is_string(as_obj.x):
as_obj.name = as_obj.x
else:
raise errors.HighchartsValueError(f'each data point supplied must either '
f'be a Bullet Data Point or be '
Expand Down
4 changes: 4 additions & 0 deletions highcharts_core/options/series/data/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def from_array(cls, value):
elif checkers.is_iterable(item):
if len(item) == 2:
as_obj = cls(x = item[0], y = item[1])
if checkers.is_string(as_obj.x):
as_obj.name = as_obj.x
elif len(item) == 1:
as_obj = cls(y = item[0])
else:
Expand Down Expand Up @@ -473,6 +475,8 @@ def from_array(cls, value):
f'collection. Collection received '
f'had {len(item)} dimensions.')
as_obj = cls.from_dict(as_dict)
if checkers.is_string(as_obj.x):
as_obj.name = as_obj.x
else:
raise errors.HighchartsValueError(f'each data point supplied must either '
f'be a Cartesian Value Data Point or be'
Expand Down
2 changes: 2 additions & 0 deletions highcharts_core/options/series/data/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def from_array(cls, value):
f'had {len(item)} dimensions.')

as_obj = cls.from_dict(as_dict)
if checkers.is_string(as_obj.x):
as_obj.name = as_obj.x
else:
raise errors.HighchartsValueError(f'each data point supplied must either '
f'be an AreaRangeData Point or be '
Expand Down
18 changes: 18 additions & 0 deletions tests/options/series/data/test_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,24 @@ def test_BarData_from_js_literal(input_files, filename, as_file, error):
Class_from_js_literal(cls, input_files, filename, as_file, error)


@pytest.mark.parametrize('array, expected, error', [
([['A', 123]], {'name': 'A', 'x': 'A', 'y': 123}, None),
([{'x': 'A', 'y': 123, 'name': 'A'}], {'name': 'A', 'x': 'A', 'y': 123}, None)
])
def test_BarData_from_array(array, expected, error):
if not expected:
expected = {}
if not error:
result = cls.from_array(array)
assert result is not None
for item in result:
assert isinstance(item, cls) is True
for key in expected:
assert getattr(item, key) == expected.get(key, None)
else:
with pytest.raises(error):
result = cls.from_array(array)

## NEXT CLASS

STANDARD_PARAMS_2 = [
Expand Down