Skip to content

Commit

Permalink
allow for numpy int types
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieTaylor-TUOS committed Mar 8, 2022
1 parent 5d85455 commit 68aa636
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A Python module for converting between the settlement periods used by GB electri
* Convert date and settlement period to Unix timestamp and vice versa.
* Convert date and settlement period to Python datetime object and vice versa.
* Convert Python datetime objects to Unix timestamp and vice versa.
* Version 0.2.0
* Version 0.2.1
* Developed and tested with Python 3.9, should work for 3.6+.

## How do I get set up? ##
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version="0.2.0",
version="0.2.1",

description="Convert between the settlement periods used by GB electricity industry and Unix timestamps.",
long_description=long_description,
Expand Down Expand Up @@ -81,7 +81,7 @@
# requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=[
"pytz",
"pytz", "numpy",
],

# List additional groups of dependencies here (e.g. development
Expand Down
3 changes: 2 additions & 1 deletion sp2ts/sp2ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from datetime import datetime, date, time, timedelta
import argparse
import pytz
import numpy as np

TRANSITION_DATES_TS = [
(954028800, 972777600), (985478400, 1004227200), (1017532800, 1035676800),
Expand Down Expand Up @@ -238,7 +239,7 @@ def _validate_timezone(name, timezone_):
# raise ValueError(f"Unknown timezone '{timezone_}'")

def _validate_timestamp(name, timestamp_):
if not isinstance(timestamp_, int):
if not isinstance(timestamp_, (int, np.int32, np.int64)):
raise TypeError(f"`{name}` must be of type int")
if timestamp_ < 0:
raise ValueError("Inavalid value for `{name}`, Unix timestamps cannot be negative")
Expand Down

0 comments on commit 68aa636

Please sign in to comment.