Modify

Ticket #20 (new defect)

Opened 8 years ago

Better Support for Numeric, and NumPy

Reported by: Numeric Owned by: 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

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will be changed from xi. Next status will be 'new'
The owner will be changed from xi to anonymous. Next status will be 'assigned'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.