Skip to content

Commit

Permalink
fix #27
Browse files Browse the repository at this point in the history
  • Loading branch information
xoolive committed Jun 9, 2019
1 parent 85a9c5b commit bb52e86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions traffic/core/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ def callsign(self) -> Union[str, Set[str], None]:
may be associated with the registration of an aircraft, its mission or
with a route for a commercial aircraft.
"""
return self._get_unique("callsign")
callsign = self._get_unique("callsign")
if callsign != callsign:
raise ValueError("NaN appearing in callsign field")
return callsign

@property
def number(self) -> Union[str, Set[str], None]:
Expand Down Expand Up @@ -389,7 +392,10 @@ def icao24(self) -> Union[str, Set[str], None]:
For example icao24 code 'ac82ec' is associated to 'N905NA'.
"""
return self._get_unique("icao24")
icao24 = self._get_unique("icao24")
if icao24 != icao24:
raise ValueError("NaN appearing in icao24 field")
return icao24

@property
def registration(self) -> Optional[str]:
Expand Down
8 changes: 7 additions & 1 deletion traffic/data/adsb/opensky_impala.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _read_cache(cachename: Path) -> Optional[pd.DataFrame]:
if count > 0:
s.seek(0)
# otherwise pandas would parse 1234e5 as 123400000.0
df = pd.read_csv(s, dtype={"icao24": str})
df = pd.read_csv(s, dtype={"icao24": str, "callsign": str})
if df.shape[0] > 0:
return df

Expand Down Expand Up @@ -382,7 +382,13 @@ def history(
continue

df = self._format_history(df)

if "last_position" in df.columns:
if df.query("last_position == last_position").shape[0] == 0:
continue

df = self._format_dataframe(df)

cumul.append(df)

if len(cumul) == 0:
Expand Down

0 comments on commit bb52e86

Please sign in to comment.