当前位置: 首页>>代码示例>>Python>>正文


Python SchemaValidator.get_parser_args方法代码示例

本文整理汇总了Python中pysemantic.validator.SchemaValidator.get_parser_args方法的典型用法代码示例。如果您正苦于以下问题:Python SchemaValidator.get_parser_args方法的具体用法?Python SchemaValidator.get_parser_args怎么用?Python SchemaValidator.get_parser_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysemantic.validator.SchemaValidator的用法示例。


在下文中一共展示了SchemaValidator.get_parser_args方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_colnames_as_callable

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_colnames_as_callable(self):
     """Test if column names work when specified as a callable."""
     schema = deepcopy(self.basespecs['iris'])
     translator = lambda x: "_".join([s.lower() for s in x.split()])
     schema['column_names'] = translator
     ideal = {'column_names': translator}
     validator = SchemaValidator(specification=schema)
     validator.get_parser_args()
     self.assertKwargsEqual(validator.df_rules, ideal)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:11,代码来源:test_validator.py

示例2: test_colnames_as_dict

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_colnames_as_dict(self):
     """Test if the column names work when specified as a dictionary."""
     schema = deepcopy(self.basespecs['iris'])
     namemap = {'Sepal Length': 'slength', 'Sepal Width': 'swidth',
                'Petal Width': 'pwidth', 'Petal Length': 'plength',
                'Species': 'spcs'}
     schema['column_names'] = namemap
     ideal = {'column_names': namemap}
     validator = SchemaValidator(specification=schema)
     validator.get_parser_args()
     self.assertKwargsEqual(validator.df_rules, ideal)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:13,代码来源:test_validator.py

示例3: test_converter

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_converter(self):
     """Test if the SeriesValidator properly applies converters."""
     schema = deepcopy(self.basespecs['iris'])
     schema['converters'] = {'Sepal Width': lambda x: int(float(x))}
     validator = SchemaValidator(specification=schema)
     filtered = pd.read_csv(**validator.get_parser_args())['Sepal Width']
     self.assertTrue(filtered.dtype == np.int)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:9,代码来源:test_validator.py

示例4: test_exclude_columns

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_exclude_columns(self):
     schema = deepcopy(self.basespecs['iris'])
     schema['exclude_columns'] = ['Sepal Length', 'Petal Width']
     validator = SchemaValidator(specification=schema)
     loaded = pd.read_csv(**validator.get_parser_args())
     self.assertItemsEqual(loaded.columns,
                           ['Petal Length', 'Sepal Width', 'Species'])
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:9,代码来源:test_validator.py

示例5: test_multifile_dataset_schema

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
    def test_multifile_dataset_schema(self):
        """Test if a dataset schema with multiple files works properly."""
        duplicate_iris_path = self.basespecs['iris']['path'].replace("iris",
                                                                     "iris2")
        # Copy the file
        dframe = pd.read_csv(self.basespecs['iris']['path'])
        dframe.to_csv(duplicate_iris_path, index=False)

        # Create the news chema
        schema = {'nrows': [150, 150], 'path': [duplicate_iris_path,
                  self.basespecs['iris']['path']]}
        for key, value in self.basespecs['iris'].iteritems():
            if key not in schema:
                schema[key] = value

        try:
            validator = SchemaValidator(specification=schema)
            self.assertTrue(validator.is_multifile)
            self.assertItemsEqual(validator.filepath, schema['path'])
            self.assertItemsEqual(validator.nrows, schema['nrows'])
            validated_args = validator.get_parser_args()
            self.assertTrue(isinstance(validated_args, list))
            self.assertEqual(len(validated_args), 2)
        finally:
            os.unlink(duplicate_iris_path)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:27,代码来源:test_validator.py

示例6: test_validator_specfile_name_iris

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_validator_specfile_name_iris(self):
     """Test if the validator works when providing specifle and name for the
     iris dataset.
     """
     validator = SchemaValidator(specfile=self.specfile, name="iris")
     validated_parser_args = validator.get_parser_args()
     self.assertKwargsEqual(validated_parser_args,
                            self.ideal_iris_parser_args)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:10,代码来源:test_validator.py

示例7: test_header

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_header(self):
     """Test if the header option works."""
     schema = deepcopy(self.basespecs['iris'])
     schema['header'] = 1
     validator = SchemaValidator(specification=schema)
     loaded = pd.read_csv(**validator.get_parser_args())
     self.assertItemsEqual(loaded.columns,
                           ['5.1', '3.5', '1.4', '0.2', 'setosa'])
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:10,代码来源:test_validator.py

示例8: test_random_rows_selection

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_random_rows_selection(self):
     """Test if the validator correctly produces the function argument
     required for selecting a range of rows from a dataset."""
     self.basespecs['iris']['nrows'] = {'range': [25, 75]}
     validator = SchemaValidator(specification=self.basespecs['iris'])
     parser_args = validator.get_parser_args()
     self.assertEqual(parser_args['skiprows'], 25)
     self.assertEqual(parser_args['nrows'], 50)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:10,代码来源:test_validator.py

示例9: test_index

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_index(self):
     """Test if specifying the index_col works."""
     specs = deepcopy(self.basespecs['iris'])
     index_col = "Species"
     specs['index_col'] = index_col
     validator = SchemaValidator(specification=specs)
     parser_args = validator.get_parser_args()
     self.assertItemsEqual(parser_args['index_col'], index_col)
开发者ID:prolificd,项目名称:pysemantic,代码行数:10,代码来源:test_validator.py

示例10: test_multiindex

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_multiindex(self):
     """Test if validator accepts list of index columns for
     multiindexing."""
     specs = deepcopy(self.basespecs['person_activity'])
     index_cols = ['tag', 'sequence_name']
     specs['index_col'] = index_cols
     validator = SchemaValidator(specification=specs)
     parser_args = validator.get_parser_args()
     self.assertItemsEqual(parser_args['index_col'], index_cols)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:11,代码来源:test_validator.py

示例11: test_pandas_defaults_empty_specs

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_pandas_defaults_empty_specs(self):
     """Test if the validator falls back to pandas defaults for empty specs.
     """
     schema = dict(path=op.join(op.abspath(op.dirname(__file__)),
                                "testdata", "iris.csv"))
     validator = SchemaValidator(specification=schema)
     ideal = pd.read_csv(schema['path'])
     actual = pd.read_csv(**validator.get_parser_args())
     self.assertDataFrameEqual(ideal, actual)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:11,代码来源:test_validator.py

示例12: test_colnames_as_list

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_colnames_as_list(self):
     """Test if the column names option works when provided as a list."""
     schema = deepcopy(self.basespecs['iris'])
     schema['header'] = 0
     ideal = ['a', 'b', 'c', 'd', 'e']
     schema['column_names'] = ideal
     validator = SchemaValidator(specification=schema)
     loaded = pd.read_csv(**validator.get_parser_args())
     self.assertItemsEqual(loaded.columns, ideal)
开发者ID:prolificd,项目名称:pysemantic,代码行数:11,代码来源:test_validator.py

示例13: test_validator_specfile_name_activity

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_validator_specfile_name_activity(self):
     """Test if the validator works when providing specifle and name for the
     activity dataset.
     """
     validator = SchemaValidator(specfile=self.specfile,
                                 name="person_activity")
     validated_parser_args = validator.get_parser_args()
     self.assertKwargsEqual(validated_parser_args,
                            self.ideal_activity_parser_args)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:11,代码来源:test_validator.py

示例14: test_parse_dates_list

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_parse_dates_list(self):
     """Test if arguments to `parse_dates` are put into a list."""
     specs = deepcopy(self.basespecs['person_activity'])
     specs['parse_dates'] = specs['parse_dates'][0]
     validator = SchemaValidator(specification=specs)
     parser_args = validator.get_parser_args()
     self.assertTrue(isinstance(parser_args['parse_dates'], list))
     df = pd.read_csv(**parser_args)
     self.assertEqual(df['date'].dtype, np.dtype('<M8[ns]'))
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:11,代码来源:test_validator.py

示例15: test_validator_with_specdist_activity

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import get_parser_args [as 别名]
 def test_validator_with_specdist_activity(self):
     """Check if the validator works when only the specification is supplied
     as a dictionary for the person activity dataset.
     """
     validator = SchemaValidator(
                            specification=self.basespecs['person_activity'])
     self.assertFalse(validator.is_multifile)
     validated = validator.get_parser_args()
     self.assertKwargsEqual(validated, self.ideal_activity_parser_args)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:11,代码来源:test_validator.py


注:本文中的pysemantic.validator.SchemaValidator.get_parser_args方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。