cldf / csvw

CSV on the web
Apache License 2.0
37 stars 6 forks source link

'double' should be a valid base data type #16

Closed Anaphory closed 6 years ago

Anaphory commented 6 years ago

If I understand the specifications correctly, then cldf inherits valid base data types from csvw, which includes the double data type from xmlschema11-2. However,

                    "datatype": "double",

in the properties of a column gives the following when run through cldf validate:

Traceback (most recent call last):
  File "/vol/home/kaipingga/.local/bin/cldf", line 11, in <module>
    load_entry_point('pycldf', 'console_scripts', 'cldf')()
  File "/vol/home/kaipingga/devel/pycldf/src/pycldf/__main__.py", line 81, in main
    sys.exit(parser.main())
  File "/vol/home/kaipingga/devel/clldutils/src/clldutils/clilib.py", line 110, in main
    catch_all=catch_all, parsed_args=args)
  File "/vol/home/kaipingga/devel/clldutils/src/clldutils/clilib.py", line 82, in main
    self.commands[args.command](args)
  File "/vol/home/kaipingga/devel/pycldf/src/pycldf/__main__.py", line 38, in validate
    ds = _get_dataset(args)
  File "/vol/home/kaipingga/devel/pycldf/src/pycldf/__main__.py", line 33, in _get_dataset
    return Dataset.from_metadata(fname)
  File "/vol/home/kaipingga/devel/pycldf/src/pycldf/dataset.py", line 313, in from_metadata
    tablegroup = TableGroup.from_file(fname)
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 688, in from_file
    res = cls.fromvalue(data)
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 192, in fromvalue
    return cls(**cls.partition_properties(d))
  File "<attrs generated init 2e6a5cf11950427ffafec070af8e1425edbaa027>", line 39, in __init__
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 680, in <lambda>
    converter=lambda v: [Table.fromvalue(vv) for vv in v])
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 680, in <listcomp>
    converter=lambda v: [Table.fromvalue(vv) for vv in v])
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 192, in fromvalue
    return cls(**cls.partition_properties(d))
  File "<attrs generated init c595c2e94b27b348864df2a549abaaad244393e0>", line 31, in __init__
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 512, in <lambda>
    converter=lambda v: Schema.fromvalue(v))
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 192, in fromvalue
    return cls(**cls.partition_properties(d))
  File "<attrs generated init fabbaea7cdd78b8af90e7acc751cf36e271cc810>", line 26, in __init__
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 469, in <lambda>
    converter=lambda v: [Column.fromvalue(c) for c in v])
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 469, in <listcomp>
    converter=lambda v: [Column.fromvalue(c) for c in v])
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 192, in fromvalue
    return cls(**cls.partition_properties(d))
  File "<attrs generated init 7ca735d4b6d02887715b57de5f557a85ffc3a1d5>", line 12, in __init__
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 337, in <lambda>
    converter=lambda v: v if not v else Datatype.fromvalue(v))
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/csvw/metadata.py", line 254, in fromvalue
    return cls(base=v)
  File "<attrs generated init 6035f4747b68af583bb309f0df6b5d88fb086a45>", line 22, in __init__
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/attr/validators.py", line 106, in __call__
    self.validator(inst, attr, value)
  File "/vol/home/kaipingga/.local/lib/python3.5/site-packages/attr/validators.py", line 145, in __call__
    name=attr.name, options=self.options, value=value
ValueError: 'base' must be in {'string': <class 'csvw.datatypes.string'>, 'float': <class 'csvw.datatypes._float'>, 'any': <class 'csvw.datatypes.anyAtomicType'>, 'gYear': <class 'csvw.datatypes.gYear'>, 'number': <class 'csvw.datatypes.number'>, 'integer': <class 'csvw.datatypes.integer'>, 'json': <class 'csvw.datatypes.json'>, 'boolean': <class 'csvw.datatypes.boolean'>, 'time': <class 'csvw.datatypes._time'>, 'html': <class 'csvw.datatypes.html'>, 'binary': <class 'csvw.datatypes.base64Binary'>, 'gMonth': <class 'csvw.datatypes.gMonth'>, 'xml': <class 'csvw.datatypes.xml'>, 'date': <class 'csvw.datatypes.date'>, 'gDay': <class 'csvw.datatypes.gDay'>, 'duration': <class 'csvw.datatypes.duration'>, 'datetime': <class 'csvw.datatypes.dateTime'>, 'dateTimeStamp': <class 'csvw.datatypes.dateTimeStamp'>, 'gYearMonth': <class 'csvw.datatypes.gYearMonth'>, 'anyURI': <class 'csvw.datatypes.anyURI'>, 'hexBinary': <class 'csvw.datatypes.hexBinary'>, 'gMonthDay': <class 'csvw.datatypes.gMonthDay'>, 'QName': <class 'csvw.datatypes.QName'>, 'decimal': <class 'csvw.datatypes.decimal'>} (got 'double')

So csvw does not provide the double data type like it should.