8000 [MRG] MNT Update liac-arff to 2.3.1 by jnothman · Pull Request #11831 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG] MNT Update liac-arff to 2.3.1 #11831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2018
Merged
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
40 changes: 20 additions & 20 deletions sklearn/externals/_arff.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
__author_email__ = ('renato.ppontes@gmail.com, '
'feurerm@informatik.uni-freiburg.de, '
'joel.nothman@gmail.com')
__version__ = '2.3'
__version__ = '2.3.1'

import re
import sys
Expand All @@ -171,7 +171,7 @@


def _build_re_values():
quoted_re = r'''(?x)
quoted_re = r'''
" # open quote followed by zero or more of:
(?:
(?<!\\) # no additional backslash
Expand All @@ -185,7 +185,7 @@ def _build_re_values():
" # close quote
'''
# a value is surrounded by " or by ' or contains no quotables
value_re = r'''(?x)(?:
value_re = r'''(?:
%s| # a value may be surrounded by "
%s| # or by '
[^,\s"'{}]+ # or may contain no characters requiring quoting
Expand Down Expand Up @@ -253,7 +253,7 @@ def _parse_values(s):
for match in _RE_SPARSE_KEY_VALUES.finditer(s):
if not match.group(1):
raise BadLayout('Error parsing %r' % match.group())
raise
raise BadLayout('Unknown parsing error')
else:
# an ARFF syntax error
for match in _RE_DENSE_VALUES.finditer(s):
Expand Down Expand Up @@ -310,7 +310,7 @@ def __init__(self, value):
)

class BadAttributeType(ArffException):
'''Error raised when some invalid type is provided into the attribute
'''Error raised when some invalid type is provided into the attribute
declaration.'''
message = 'Bad @ATTRIBUTE type, at line %d.'

Expand All @@ -327,7 +327,7 @@ def __init__(self, value, value2):
)

class BadNominalValue(ArffException):
'''Error raised when a value in used in some data instance but is not
'''Error raised when a value in used in some data instance but is not
declared into it respective attribute declaration.'''

def __init__(self, value):
Expand All @@ -347,7 +347,7 @@ def __init__(self, value):
)

class BadNumericalValue(ArffException):
'''Error raised when and invalid numerical value is used in some data
'''Error raised when and invalid numerical value is used in some data
instance.'''
message = 'Invalid numerical value, at line %d.'

Expand All @@ -365,14 +365,14 @@ def __init__(self, msg=''):
self.message = BadLayout.message + ' ' + msg.replace('%', '%%')

class BadObject(ArffException):
'''Error raised when the object representing the ARFF file has something
'''Error raised when the object representing the ARFF file has something
wrong.'''

def __str__(self):
return 'Invalid object.'

class BadObject(ArffException):
'''Error raised when the object representing the ARFF file has something
'''Error raised when the object representing the ARFF file has something
wrong.'''
def __init__(self, msg=''):
self.msg = msg
Expand Down Expand Up @@ -636,7 +636,7 @@ def _decode_comment(self, s):
characters.

This method must receive a normalized string, i.e., a string without
padding, including the "\r\n" characters.
padding, including the "\r\n" characters.

:param s: a normalized string.
:return: a string with the decoded comment.
Expand All @@ -647,13 +647,13 @@ def _decode_comment(self, s):
def _decode_relation(self, s):
'''(INTERNAL) Decodes a relation line.

The relation declaration is a line with the format ``@RELATION
The relation declaration is a line with the format ``@RELATION
<relation-name>``, where ``relation-name`` is a string. The string must
start with alphabetic character and must be quoted if the name includes
spaces, otherwise this method will raise a `BadRelationFormat` exception.

This method must receive a normalized string, i.e., a string without
padding, including the "\r\n" characters.
padding, including the "\r\n" characters.

:param s: a normalized string.
:return: a string with the decoded relation name.
Expand All @@ -670,26 +670,26 @@ def _decode_relation(self, s):
def _decode_attribute(self, s):
'''(INTERNAL) Decodes an attribute line.

The attribute is the most complex declaration in an arff file. All
The attribute is the most complex declaration in an arff file. All
attributes must follow the template::

@attribute <attribute-name> <datatype>

where ``attribute-name`` is a string, quoted if the name contains any
where ``attribute-name`` is a string, quoted if the name contains any
whitespace, and ``datatype`` can be:

- Numerical attributes as ``NUMERIC``, ``INTEGER`` or ``REAL``.
- Strings as ``STRING``.
- Dates (NOT IMPLEMENTED).
- Nominal attributes with format:

{<nominal-name1>, <nominal-name2>, <nominal-name3>, ...}
{<nominal-name1>, <nominal-name2>, <nominal-name3>, ...}

The nominal names follow the rules for the attribute names, i.e., they
must be quoted if the name contains whitespaces.

This method must receive a normalized string, i.e., a string without
padding, including the "\r\n" characters.
padding, including the "\r\n" characters.

:param s: a normalized string.
:return: a tuple (ATTRIBUTE_NAME, TYPE_OR_VALUES).
Expand Down Expand Up @@ -874,8 +874,8 @@ def _encode_comment(self, s=''):
def _encode_relation(self, name):
'''(INTERNAL) Decodes a relation line.

The relation declaration is a line with the format ``@RELATION
<relation-name>``, where ``relation-name`` is a string.
The relation declaration is a line with the format ``@RELATION
<relation-name>``, where ``relation-name`` is a string.

:param name: a string.
:return: a string with the encoded relation declaration.
Expand All @@ -901,7 +901,7 @@ def _encode_attribute(self, name, type_):
- Dates (NOT IMPLEMENTED).
- Nominal attributes with format:

{<nominal-name1>, <nominal-name2>, <nominal-name3>, ...}
{<nominal-name1>, <nominal-name2>, <nominal-name3>, ...}

This method must receive a the name of the attribute and its type, if
the attribute type is nominal, ``type`` must be a list of values.
Expand Down Expand Up @@ -936,7 +936,7 @@ def encode(self, obj):
def iter_encode(self, obj):
'''The iterative version of `arff.ArffEncoder.encode`.

This encodes iteratively a given object and return, one-by-one, the
This encodes iteratively a given object and return, one-by-one, the
lines of the ARFF file.

:param obj: the object containing the ARFF information.
Expand Down
0