From 051377ec66837d4cb40e8e6158de0de7fdfa9b3d Mon Sep 17 00:00:00 2001 From: Vince Date: Tue, 14 May 2019 23:46:02 -0400 Subject: [PATCH 1/2] rename ordered path expander; #34 --- attmap/__init__.py | 4 ++-- attmap/_version.py | 2 +- attmap/attmap_echo.py | 4 ++-- attmap/{ordpathex_attmap.py => pathex_attmap.py} | 6 +++--- docs/changelog.md | 4 ++++ tests/conftest.py | 2 +- tests/test_attmap_equality.py | 8 ++++---- tests/test_ordattmap.py | 12 ++++++------ tests/test_packaging.py | 2 +- tests/test_path_expansion.py | 2 +- 10 files changed, 25 insertions(+), 21 deletions(-) rename attmap/{ordpathex_attmap.py => pathex_attmap.py} (77%) diff --git a/attmap/__init__.py b/attmap/__init__.py index 4282b8b..c67d6f4 100644 --- a/attmap/__init__.py +++ b/attmap/__init__.py @@ -4,11 +4,11 @@ from .attmap_echo import AttMapEcho from .helpers import * from .ordattmap import OrdAttMap -from .ordpathex_attmap import OrdPathExAttMap +from .pathex_attmap import PathExAttMap from ._version import __version__ AttributeDict = AttMap AttributeDictEcho = AttMapEcho __all__ = ["AttMap", "AttMapEcho", "AttributeDict", "AttributeDictEcho", - "OrdAttMap", "OrdPathExAttMap", "get_data_lines"] + "OrdAttMap", "PathExAttMap", "get_data_lines"] diff --git a/attmap/_version.py b/attmap/_version.py index 26421e1..1e0672b 100644 --- a/attmap/_version.py +++ b/attmap/_version.py @@ -1 +1 @@ -__version__ = "0.8" +__version__ = "0.9dev" diff --git a/attmap/attmap_echo.py b/attmap/attmap_echo.py index becbd6a..b865753 100644 --- a/attmap/attmap_echo.py +++ b/attmap/attmap_echo.py @@ -1,9 +1,9 @@ """ AttMap that echoes an unset key/attr """ -from .ordpathex_attmap import OrdPathExAttMap +from .pathex_attmap import PathExAttMap -class AttMapEcho(OrdPathExAttMap): +class AttMapEcho(PathExAttMap): """ An AttMap that returns key/attr if it has no set value. """ def __getattr__(self, item, default=None): diff --git a/attmap/ordpathex_attmap.py b/attmap/pathex_attmap.py similarity index 77% rename from attmap/ordpathex_attmap.py rename to attmap/pathex_attmap.py index c98a11a..bee30fa 100644 --- a/attmap/ordpathex_attmap.py +++ b/attmap/pathex_attmap.py @@ -7,14 +7,14 @@ __email__ = "vreuter@virginia.edu" -__all__ = ["OrdPathExAttMap"] +__all__ = ["PathExAttMap"] -class OrdPathExAttMap(OrdAttMap): +class PathExAttMap(OrdAttMap): """ Used in pepkit projects, with Mapping conversion and path expansion """ @property def _transformations(self): """ Add path expansion behavior to more general attmap. """ - return super(OrdPathExAttMap, self)._transformations + \ + return super(PathExAttMap, self)._transformations + \ [(lambda obj: isinstance(obj, str), expandpath)] diff --git a/docs/changelog.md b/docs/changelog.md index 67209be..0daeaf1 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,9 @@ # Changelog +## [0.9] - 2019-05-15 +### Changed +- `OrdPathAttExAttMap` is now `PathExAttMap`. + ## [0.8] - 2019-05-13 ### Added - `OrdAttMap` to create maps that preserve insertion order and otherwise behave like ordinary `AttMap` diff --git a/tests/conftest.py b/tests/conftest.py index 6b3d655..3454ef4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,7 +8,7 @@ ALL_ATTMAPS = [AttributeDict, AttributeDictEcho, AttMap, OrdAttMap, AttMapEcho, - OrdPathExAttMap] + PathExAttMap] @pytest.fixture(scope="function", params=ALL_ATTMAPS) diff --git a/tests/test_attmap_equality.py b/tests/test_attmap_equality.py index 03dd3b8..358a75d 100644 --- a/tests/test_attmap_equality.py +++ b/tests/test_attmap_equality.py @@ -4,7 +4,7 @@ import numpy as np from pandas import DataFrame as DF, Series import pytest -from attmap import AttMap, OrdAttMap, OrdPathExAttMap, AttMapEcho +from attmap import AttMap, OrdAttMap, PathExAttMap, AttMapEcho from .conftest import ALL_ATTMAPS from .helpers import get_att_map @@ -56,10 +56,10 @@ def test_eq_with_scistack_value_types(attmap_type, obj1, obj2, expected): @pytest.mark.parametrize("data", [{}, {"a": 1}]) @pytest.mark.parametrize(["this_type", "that_type", "exp"], [ (AttMap, AttMap, True), - (AttMap, AttMapEcho, False), (AttMap, OrdAttMap, False), (AttMap, OrdPathExAttMap, False), + (AttMap, AttMapEcho, False), (AttMap, OrdAttMap, False), (AttMap, PathExAttMap, False), (OrdAttMap, OrdAttMap, True), - (OrdAttMap, OrdPathExAttMap, False), (OrdAttMap, AttMapEcho, False), - (OrdPathExAttMap, OrdPathExAttMap, True), (OrdPathExAttMap, AttMapEcho, False), + (OrdAttMap, PathExAttMap, False), (OrdAttMap, AttMapEcho, False), + (PathExAttMap, PathExAttMap, True), (PathExAttMap, AttMapEcho, False), (AttMapEcho, AttMapEcho, True)]) def test_equality_is_strict_in_type(data, this_type, that_type, exp): """ Attmap equality requires exact type match. """ diff --git a/tests/test_ordattmap.py b/tests/test_ordattmap.py index 9ad4d36..36d2bd3 100644 --- a/tests/test_ordattmap.py +++ b/tests/test_ordattmap.py @@ -6,7 +6,7 @@ import pytest from hypothesis import given from hypothesis.strategies import * -from attmap import AttMap, AttMapEcho, OrdAttMap, OrdPathExAttMap +from attmap import AttMap, AttMapEcho, OrdAttMap, PathExAttMap __author__ = "Vince Reuter" __email__ = "vreuter@virginia.edu" @@ -38,7 +38,7 @@ def kv_lists_strategy(pool=(integers, text, characters, uuids), **kwargs): @pytest.mark.parametrize(["cls", "exp"], [ (OrdAttMap, True), (OrderedDict, True), (AttMap, True), - (OrdPathExAttMap, False), (AttMapEcho, False)]) + (PathExAttMap, False), (AttMapEcho, False)]) def test_subclassing(cls, exp): """ Verify that OrdAttMap type has expected type memberships. """ assert exp is issubclass(OrdAttMap, cls) @@ -46,7 +46,7 @@ def test_subclassing(cls, exp): @pytest.mark.parametrize(["cls", "exp"], [ (OrdAttMap, True), (OrderedDict, True), (AttMap, True), - (OrdPathExAttMap, False), (AttMapEcho, False)]) + (PathExAttMap, False), (AttMapEcho, False)]) def test_type_membership(cls, exp): """ Verify that an OrdAttMap instance passes type checks as expected. """ assert exp is isinstance(OrdAttMap(), cls) @@ -115,7 +115,7 @@ def test_ordattmap_deletion(hwy_dat_key, raw_hwy_dat, alter, check): assert check(orig, obs), "Expected {} but found {}".format(orig, obs) -@pytest.mark.parametrize("base_type", [OrdAttMap, OrdPathExAttMap]) +@pytest.mark.parametrize("base_type", [OrdAttMap, PathExAttMap]) @pytest.mark.parametrize( ["that_type", "final_exp"], [(dict, sys.version_info >= (3, 6)), (OrderedDict, True), (OrdAttMap, True)]) @@ -166,7 +166,7 @@ def _excl_from_repr(self, k, cls): @pytest.mark.parametrize(["that_type", "exp"], [ (OrdAttMap, True), (AttMapEcho, False), (AttMap, False), - (OrdPathExAttMap, False), (OrderedDict, False), (dict, False)]) + (PathExAttMap, False), (OrderedDict, False), (dict, False)]) def test_ordattmap_repr(raw_hwy_dat, that_type, exp): """ Test __repr__ of OrdAttMap. """ assert exp is (repr(OrdAttMap(raw_hwy_dat)) == repr(that_type(raw_hwy_dat))) @@ -178,7 +178,7 @@ class BasicDataTests: BASIC_DATA = [("a", OrderedDict([("c", 3), ("b", 2)])), ("d", 4), ("e", OrderedDict([("f", 6)]))] - @pytest.fixture(params=[OrdAttMap, OrdPathExAttMap]) + @pytest.fixture(params=[OrdAttMap, PathExAttMap]) def oam(self, request): """ Provide test case with a simple ordered attmap instance. """ return request.param(self.BASIC_DATA) diff --git a/tests/test_packaging.py b/tests/test_packaging.py index fe8ce0d..9ec82ff 100644 --- a/tests/test_packaging.py +++ b/tests/test_packaging.py @@ -9,7 +9,7 @@ @pytest.mark.parametrize( ["obj_name", "typecheck"], - [("AttMap", isclass), ("OrdAttMap", isclass), ("OrdPathExAttMap", isclass), + [("AttMap", isclass), ("OrdAttMap", isclass), ("PathExAttMap", isclass), ("AttMapEcho", isclass), ("get_data_lines", isfunction)]) def test_top_level_exports(obj_name, typecheck): """ At package level, validate object availability and type. """ diff --git a/tests/test_path_expansion.py b/tests/test_path_expansion.py index 767ba2e..530b9de 100644 --- a/tests/test_path_expansion.py +++ b/tests/test_path_expansion.py @@ -20,7 +20,7 @@ @pytest.fixture(scope="function") def pam(): """ Provide a test case with a clean/fresh map. """ - return OrdPathExAttMap() + return PathExAttMap() class TmpEnv(object): From bc1de54f7eff6a294136ec67ef85ed8415cd8fea Mon Sep 17 00:00:00 2001 From: Vince Date: Tue, 14 May 2019 23:48:30 -0400 Subject: [PATCH 2/2] version and changelog for release --- attmap/_version.py | 2 +- docs/changelog.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/attmap/_version.py b/attmap/_version.py index 1e0672b..824978d 100644 --- a/attmap/_version.py +++ b/attmap/_version.py @@ -1 +1 @@ -__version__ = "0.9dev" +__version__ = "0.9" diff --git a/docs/changelog.md b/docs/changelog.md index 0daeaf1..ddcc47f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,6 +1,6 @@ # Changelog -## [0.9] - 2019-05-15 +## [0.9] - 2019-05-14 ### Changed - `OrdPathAttExAttMap` is now `PathExAttMap`.