class TestWithListAndDictArgs: expected = [0, 0] # I mapping_arg = gg.aes('X') expected[0] = dict(geom='n', data_meta={}, mapping=mapping_arg.as_dict()) # II expected[1] = dict(geom='n', mapping={}, data_meta={}, arrow={ 'angle': 0, 'length': 1, 'ends': 'a', 'type': 'b', 'name': 'arrow' }) @pytest.mark.parametrize( 'args_list,args_dict,expected', [(['n'], dict(mapping=mapping_arg, ), expected[0]), (['n'], { 'arrow': arrow(0, 1, 'a', 'b') }, expected[1])]) def test_aes(self, args_list, args_dict, expected): spec = _geom(*args_list, **args_dict) assert spec.as_dict() == expected
class TestWithListAndDictArgs: expected = [0, 0] # I mapping_arg = gg.aes('X') pos_args = ['n', mapping_arg, 'd', 's', 'p', 'sl'] other_args = {'size': 10, 'fill': 'red'} expected[0] = dict(geom='n', mapping=mapping_arg.as_dict(), data='d', stat='s', position='p', show_legend='sl', **other_args) # II expected[1] = dict(geom='n', mapping=None, data=None, stat=None, position=None, show_legend=None, arrow={ 'angle': 0, 'length': 1, 'ends': 'a', 'type': 'b', 'name': 'arrow' }) @pytest.mark.parametrize('args_list,args_dict,expected', [(pos_args, other_args, expected[0]), (['n'], { 'arrow': arrow(0, 1, 'a', 'b') }, expected[1])]) def test_aes(self, args_list, args_dict, expected): spec = _geom(*args_list, **args_dict) assert spec.as_dict() == expected
def test_aes(self, args, expected): spec = gg.aes(**args) assert spec.as_dict() == expected
# # Copyright (c) 2019. JetBrains s.r.o. # Use of this source code is governed by the MIT license that can be found in the LICENSE file. # import pytest import lets_plot as gg data = {'a': [1, 2], 'b': [3, 4]} mapping_empty = gg.aes() mapping_x = gg.aes('X') result_empty = {'kind': 'plot', 'mapping': {}, 'data_meta': {}, 'layers': [], 'scales': []} result_data = {'data': data, 'kind': 'plot', 'mapping': {}, 'data_meta': {}, 'layers': [], 'scales': []} result_data_mapping_empty = {'data': data, 'kind': 'plot', 'mapping': {}, 'data_meta': {}, 'layers': [], 'scales': []} result_data_mapping_x = {'data': data, 'mapping': {'x': 'X'}, 'data_meta': {}, 'kind': 'plot', 'layers': [], 'scales': []} result_mapping_x = {'mapping': {'x': 'X'}, 'data_meta': {}, 'kind': 'plot', 'layers': [], 'scales': []} @pytest.mark.parametrize('args,expected', [ ([], result_empty), ([data], result_data), ([data, mapping_empty], result_data_mapping_empty), ([data, mapping_x], result_data_mapping_x), ([None, mapping_x], result_mapping_x), ]) def test_ggplot(args, expected): spec = gg.ggplot(*args) assert spec.as_dict() == expected