MCPcopy Index your code
hub / github.com/numpy/numpy / _strict_call

Method _strict_call

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

Source from the content-addressed store, hash-verified

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