Ticket #20 (new defect)

Opened 2 years ago

Better Support for Numeric, and NumPy

Reported by: Numeric Assigned to: xi
Priority: normal Component: pyyaml
Severity: normal Keywords:
Cc:

Description

Would like better support for Numeric and NumPy?. In the old pyYaml created an extension that would correctly output Numeric arrays as a redable list. Would be nice if the baseline version of Yaml could do the same.

--- !!Numeric.array
  - 1.0
  - 2.0
  - 3.0
$ grep -A 10 ECS "c:\python24\lib\site-packages\yaml\constructor.py"
    #ECS added
    def construct_Numeric_array(self, node):
        from numpy import array
        if not isinstance(node, SequenceNode):
            raise ConstructorError(None, None,
                    "expected a sequence node, but found %s" % node.id,
                    node.start_mark)
        return array([self.construct_object(child) for child in node.value])

    def construct_mapping(self, node):
        if not isinstance(node, MappingNode):
--
    #ECS added
    def construct_yaml_Numeric_array(self, node):
        return self.construct_Numeric_array(node)

    def construct_yaml_map(self, node):
        return self.construct_mapping(node)

    def construct_yaml_object(self, node, cls):
        state = self.construct_mapping(node)
        data = cls.__new__(cls)
        if hasattr(data, '__setstate__'):
--
#ECS added
SafeConstructor.add_constructor(
        u'tag:yaml.org,2002:Numeric.array',
        SafeConstructor.construct_yaml_Numeric_array)

SafeConstructor.add_constructor(None,
        SafeConstructor.construct_undefined)

class Constructor(SafeConstructor):

    def construct_python_str(self, node):

Attachments


Add/Change #20 (Better Support for Numeric, and NumPy)




Change Properties
Action