MCPcopy Create free account
hub / github.com/numpy/numpy / upgrade

Method upgrade

numpy/lib/_iotools.py:724–750  ·  view source on GitHub ↗

Find the best converter for a given string, and return the result. The supplied string `value` is converted by testing different converters in order. First the `func` method of the `StringConverter` instance is tried, if this fails other available converters

(self, value)

Source from the content-addressed store, hash-verified

722 self.default = default
723
724 def upgrade(self, value):
725 """
726 Find the best converter for a given string, and return the result.
727
728 The supplied string `value` is converted by testing different
729 converters in order. First the `func` method of the
730 `StringConverter` instance is tried, if this fails other available
731 converters are tried. The order in which these other converters
732 are tried is determined by the `_status` attribute of the instance.
733
734 Parameters
735 ----------
736 value : str
737 The string to convert.
738
739 Returns
740 -------
741 out : any
742 The result of converting `value` with the appropriate converter.
743
744 """
745 self._checked = True
746 try:
747 return self._strict_call(value)
748 except ValueError:
749 self._do_upgrade()
750 return self.upgrade(value)
751
752 def iterupgrade(self, value):
753 self._checked = True

Callers 4

test_upgradeMethod · 0.95
test_missingMethod · 0.95
test_keep_defaultMethod · 0.95
genfromtxtFunction · 0.80

Calls 2

_strict_callMethod · 0.95
_do_upgradeMethod · 0.95

Tested by 3

test_upgradeMethod · 0.76
test_missingMethod · 0.76
test_keep_defaultMethod · 0.76