Skip to content

REF: make Fixed.version a property #29765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os
import re
import time
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, Union
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union
import warnings

import numpy as np
Expand Down Expand Up @@ -2560,21 +2560,22 @@ def __init__(self, parent, group, encoding=None, errors="strict", **kwargs):
self.group = group
self.encoding = _ensure_encoding(encoding)
self.errors = errors
self.set_version()

@property
def is_old_version(self) -> bool:
return self.version[0] <= 0 and self.version[1] <= 10 and self.version[2] < 1

def set_version(self):
@property
def version(self) -> Tuple[int, int, int]:
""" compute and set our version """
version = _ensure_decoded(getattr(self.group._v_attrs, "pandas_version", None))
try:
self.version = tuple(int(x) for x in version.split("."))
if len(self.version) == 2:
self.version = self.version + (0,)
version = tuple(int(x) for x in version.split("."))
if len(version) == 2:
version = version + (0,)
except AttributeError:
self.version = (0, 0, 0)
version = (0, 0, 0)
return version

@property
def pandas_type(self):
Expand All @@ -2600,7 +2601,6 @@ def set_object_info(self):
""" set my pandas type & version """
self.attrs.pandas_type = str(self.pandas_kind)
self.attrs.pandas_version = str(_version)
self.set_version()

def copy(self):
new_self = copy.copy(self)
Expand Down