Skip to content

Commit

Permalink
CLN: Restore Union[int, float]
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtage committed Jan 21, 2020
1 parent 64223dc commit 9eff8b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,7 @@ def to_stata(
# mypy: Name 'statawriter' already defined (possibly by an import)
from pandas.io.stata import StataWriterUTF8 as statawriter # type:ignore

kwargs: Dict[str, Any] = {}
kwargs: Dict[str, Any] = {}
if version is None or version >= 117:
# strl conversion is only supported >= 117
kwargs["convert_strl"] = convert_strl
Expand Down
21 changes: 5 additions & 16 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,11 @@
from collections import abc
import datetime
from io import BytesIO, IOBase
from pathlib import Path
import os
from pathlib import Path
import struct
import sys
from typing import (
Any,
AnyStr,
BinaryIO,
Dict,
IO,
List,
Optional,
Sequence,
Tuple,
Union,
)
from typing import Any, AnyStr, BinaryIO, Dict, List, Optional, Sequence, Tuple, Union
import warnings

from dateutil.relativedelta import relativedelta
Expand Down Expand Up @@ -762,7 +751,7 @@ class StataMissingValue:
"float64": struct.unpack("<d", float64_base)[0],
}

def __init__(self, value: float):
def __init__(self, value: Union[int, float]):
self._value = value
# Conversion to int to avoid hash issues on 32 bit platforms #8968
value = int(value) if value < 2147483648 else float(value)
Expand All @@ -781,7 +770,7 @@ def string(self) -> str:
return self._str

@property
def value(self) -> float:
def value(self) -> Union[int, float]:
"""
The binary representation of the missing value.
Expand All @@ -806,7 +795,7 @@ def __eq__(self, other: Any) -> bool:
)

@classmethod
def get_base_missing_value(cls, dtype: np.dtype) -> float:
def get_base_missing_value(cls, dtype: np.dtype) -> Union[int, float]:
if dtype == np.int8:
value = cls.BASE_MISSING_VALUES["int8"]
elif dtype == np.int16:
Expand Down

0 comments on commit 9eff8b1

Please sign in to comment.