Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamzu24 committed Dec 3, 2024
1 parent c04da0c commit 86380f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions packages/schema_wrapper/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ def _todict(obj: Any, context: dict[str, Any] | None = None, np_opt: Any = None,
elif (
hasattr(obj, "to_dict")
and (module_name := obj.__module__)
and module_name.startswith("altair")
#and module_name.startswith("altair")
):
return obj.to_dict()
return obj.to_dict(False)
elif pd_opt is not None and isinstance(obj, pd_opt.Timestamp):
return pd_opt.Timestamp(obj).isoformat()
elif _is_iterable(obj, exclude=(str, bytes)):
Expand Down Expand Up @@ -331,4 +331,3 @@ def to_dict(
except jsonschema.ValidationError as err:
raise SchemaValidationError(self, err) from None
return result

6 changes: 4 additions & 2 deletions packages/schema_wrapper/test/test_generated_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_weather_plot():
'rRange': [2, 10],
'width': 800,
'xTickFormat': '%b',
'xyDomain': 'Fixed'} == to_dict(plot_spec))
'xyDomain': 'Fixed'} == _todict(plot_spec))

def test_stock_plot():
plot_spec = Plot(
Expand All @@ -155,14 +155,16 @@ def test_stock_plot():
width = 680,
height = 200
)
dict_rep = _todict(plot_spec)
print(f"rep: {dict_rep}")
assert({'height': 200,
'plot': [
{'data': {'from': 'aapl'},
'mark': 'lineY',
'x': 'Date',
'y': 'Close'}
],
'width': 680} == to_dict(plot_spec))
'width': 680} == _todict(plot_spec))

if __name__ == '__main__':
pytest.main([__file__])
Expand Down

0 comments on commit 86380f9

Please sign in to comment.