diff --git a/tagmaps/classes/load_data.py b/tagmaps/classes/load_data.py index 311150b..1a1db41 100644 --- a/tagmaps/classes/load_data.py +++ b/tagmaps/classes/load_data.py @@ -298,21 +298,20 @@ def get_cleaned_location(self, first_post, locid_userid, post_latlng -- tuple with lat/lng coordinates user_key -- user_guid """ - cleaned_post = CleanedPost() # named tuple structure - cleaned_post.origin_id = first_post.origin_id - cleaned_post.lat = float(post_latlng[0]) - cleaned_post.long = float(post_latlng[1]) - cleaned_post.guid = first_post.guid - cleaned_post.user_guid = user_key - cleaned_post.post_body = \ - self.userlocation_wordlist_dict.get( - locid_userid, ("",)) # ("",) = substitute default - cleaned_post.post_create_date = first_post.post_create_date - cleaned_post.post_publish_date = first_post.post_publish_date - cleaned_post.post_views_count = first_post.post_views_count - cleaned_post.hashtags = \ - self.userlocation_taglist_dict.get(locid_userid, ("",)) - cleaned_post.loc_id = first_post.loc_id + cleaned_post = CleanedPost( + origin_id=first_post.origin_id, + lat=float(post_latlng[0]), + long=float(post_latlng[1]), + guid=first_post.guid, + user_guid=user_key, + post_body=self.userlocation_wordlist_dict.get( + locid_userid, ("",)), # ("",)=substitute default + post_create_date=first_post.post_create_date, + post_publish_date=first_post.post_publish_date, + post_views_count=first_post.post_views_count, + hashtags=self.userlocation_taglist_dict.get(locid_userid, ("",)), + loc_id=first_post.loc_id + ) # named tuple structure return cleaned_post @staticmethod diff --git a/tagmaps/classes/shared_structure.py b/tagmaps/classes/shared_structure.py index b6018a0..47449ff 100644 --- a/tagmaps/classes/shared_structure.py +++ b/tagmaps/classes/shared_structure.py @@ -49,11 +49,18 @@ def __init__(self): self.loc_id = None -"""This auto-class provides a structure for fast handling -of essential post attributes for use in tag maps clustering +"""This auto-class generated from named structure + +provides access for fast handling +of essential post attributes +for use in tag maps clustering + +- namedtuple instances are just as memory +efficient as regular tuples because they +do not have per-instance dictionaries. """ CleanedPost = namedtuple( - 'cleanedPostLocation_tuple', + 'CleanedPost', 'origin_id lat lng guid user_guid ' 'post_create_date post_publish_date ' 'post_body hashtags emoji '