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

Method _strict_call

numpy/lib/_iotools.py:676–699  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

674 return self.default
675
676 def _strict_call(self, value):
677 try:
678
679 # We check if we can convert the value using the current function
680 new_value = self.func(value)
681
682 # In addition to having to check whether func can convert the
683 # value, we also have to make sure that we don't get overflow
684 # errors for integers.
685 if self.func is int:
686 try:
687 np.array(value, dtype=self.type)
688 except OverflowError:
689 raise ValueError
690
691 # We're still here so we can now return the new value
692 return new_value
693
694 except ValueError:
695 if value.strip() in self.missing_values:
696 if not self._status:
697 self._checked = False
698 return self.default
699 raise ValueError("Cannot convert string '%s'" % value)
700
701 def __call__(self, value):
702 return self._callingfunction(value)

Callers 2

upgradeMethod · 0.95
genfromtxtFunction · 0.80

Calls 2

stripMethod · 0.80
funcMethod · 0.45

Tested by

no test coverage detected