Repository: mie-lab/trackintel (language: python)

Issue:
Remove user from model?
In the folder model we have the file `user.py`, apparently it is no longer part of our data model &rarr; suggestion to remove it.


Discussion / hints:

Fix patch:
diff --git a/docs/modules/model.rst b/docs/modules/model.rst
index ce549437..139b2a10 100644
--- a/docs/modules/model.rst
+++ b/docs/modules/model.rst
@@ -6,7 +6,6 @@ assumed that data is already available in all these classes, instead, trackintel
 provides functionality to generate everything starting from the raw GPS positionfix data 
 (consisting of at least ``(user_id, tracked_at, longitude, latitude)`` tuples).
 
-* **users**: The users for which data is available.
 * **positionfixes**: Raw GPS data.
 * **staypoints**: Locations where a user spent a minimal time.
 * **triplegs**: Segments covered with one mode of transport.
@@ -57,12 +56,6 @@ Available Accessors
 
 The following accessors are available within *trackintel*.
 
-UsersAccessor
--------------
-
-.. autoclass:: trackintel.model.users.UsersAccessor
-	:members:
-
 PositionfixesAccessor
 ---------------------
 
@@ -114,27 +107,6 @@ in case you want to quickly set up a database. Also take a look at the `example
 
 .. highlight:: sql
 
-The **users** table contains information about individual users for which mobility data is available 
-(i.e., each ``user_id`` appearing in the tables below should have a corresponding user in the ``users``
-table)::
-
-    CREATE TABLE users (
-        -- Common to all tables.
-        id bigint NOT NULL,
-
-        -- Specific attributes.
-        -- The attributes contain additional information that might be given for each user. This
-        -- could be demographic information, such as age, gender, or income. 
-        attributes json,
-
-        -- Spatial attributes.
-        geom_home geometry(Point, 4326),
-        geom_work geometry(Point, 4326),
-
-        -- Constraints.
-        CONSTRAINT users_pkey PRIMARY KEY (id)
-    );
-
 The **positionfixes** table contains all positionfixes (i.e., all individual GPS trackpoints, 
 consisting of longitude, latitude and timestamp) of all users. They are not only linked to 
 a user, but also (potentially, if this link has already been made) to a tripleg or a staypoint::
diff --git a/sql/create_tables_pg.sql b/sql/create_tables_pg.sql
index 4e1ce7d1..1da4756d 100644
--- a/sql/create_tables_pg.sql
+++ b/sql/create_tables_pg.sql
@@ -3,23 +3,6 @@
 
 CREATE EXTENSION PostGIS;
 
-CREATE TABLE users (
-    -- Common to all tables.
-    id bigint NOT NULL,
-
-    -- Specific attributes.
-    -- The attributes contain additional information that might be given for each user. This
-    -- could be demographic information, such as age, gender, or income. 
-    attributes json,
-
-    -- Spatial attributes.
-    geom_home geometry(Point, 4326),
-    geom_work geometry(Point, 4326),
-
-    -- Constraints.
-    CONSTRAINT users_pkey PRIMARY KEY (id)
-);
-
 CREATE TABLE positionfixes (
     -- Common to all tables.
     id bigint NOT NULL,
diff --git a/trackintel/model/__init__.py b/trackintel/model/__init__.py
index f94f55f8..f24d9dd7 100644
--- a/trackintel/model/__init__.py
+++ b/trackintel/model/__init__.py
@@ -3,5 +3,4 @@
 from .triplegs import TriplegsAccessor
 from .locations import LocationsAccessor
 from .trips import TripsAccessor
-from .users import UsersAccessor
 from .tours import ToursAccessor
diff --git a/trackintel/model/users.py b/trackintel/model/users.py
deleted file mode 100644
index 01f391c4..00000000
--- a/trackintel/model/users.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import pandas as pd
-import trackintel as ti
-
-
-@pd.api.extensions.register_dataframe_accessor("as_users")
-class UsersAccessor(object):
-    """A pandas accessor to treat DataFrames as collections of users.
-
-    This will define certain methods and accessors, as well as make sure that the DataFrame
-    adheres to some requirements.
-
-    Requires at least the following columns:
-    ['id']
-
-    For several usecases, the following additional columns are required:
-    ['attributes', 'geom_home', 'geom_work']
-
-    Examples
-    --------
-    >>> df.as_users.plot_home_and_work()
-    """
-
-    required_columns = ["id"]
-
-    def __init__(self, pandas_obj):
-        self._validate(pandas_obj)
-        self._obj = pandas_obj
-
-    @staticmethod
-    def _validate(obj):
-        if any([c not in obj.columns for c in UsersAccessor.required_columns]):
-            raise AttributeError(
-                "To process a DataFrame as a collection of users, "
-                + "it must have the properties [%s], but it has [%s]."
-                % (", ".join(UsersAccessor.required_columns), ", ".join(obj.columns))
-            )
-
-    def plot_home_and_work(self):
-        """
-        Plot home and work locations of users.
-
-        See :func:`trackintel.visualization.users.plot_home_and_work`.
-        """
-        raise NotImplementedError


Test patch:
diff --git a/tests/model/test_users.py b/tests/model/test_users.py
deleted file mode 100644
index efec6485..00000000
--- a/tests/model/test_users.py
+++ /dev/null
@@ -1,20 +0,0 @@
-import os
-import pytest
-
-import trackintel as ti
-
-
-class TestUsers:
-    """Tests for the UsersAccessor."""
-
-    def test_accessor(self):
-        """Test if the as_users accessor checks the required column for users."""
-        pfs, _ = ti.io.dataset_reader.read_geolife(os.path.join("tests", "data", "geolife_long"))
-
-        users = pfs.groupby("user_id", as_index=False).mean()
-        users.rename(columns={"user_id": "id"}, inplace=True)
-        assert users.as_users
-
-        users = users.drop(["id"], axis=1)
-        with pytest.raises(AttributeError):
-            users.as_users