Repository: mie-lab/trackintel
Pull request #192 (2021-04-01 14:02:55)

TST/CLN: Clean model
a clean up of model module. Tests are added for each accessor. Docstring format updated.

No content or functionality should change

codecov[bot]: # [Codecov](https://codecov.io/gh/mie-lab/trackintel/pull/192?src=pr&el=h1) Report
> Merging [#192](https://codecov.io/gh/mie-lab/trackintel/pull/192?src=pr&el=desc) (226fb34) into [master](https://codecov.io/gh/mie-lab/trackintel/commit/948e1051e1423d0731dcfe4d986940ea0272173a?el=desc) (948e105) will **increase** coverage by `1.26%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/mie-lab/trackintel/pull/192/graphs/tree.svg?width=650&height=150&src=pr&token=ITDZEEE1MO)](https://codecov.io/gh/mie-lab/trackintel/pull/192?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #192      +/-   ##
==========================================
+ Coverage   83.85%   85.11%   +1.26%     
==========================================
  Files          36       36              
  Lines        1561     1559       -2     
  Branches      287      287              
==========================================
+ Hits         1309     1327      +18     
+ Misses        183      170      -13     
+ Partials       69       62       -7     
```


| [Impacted Files](https://codecov.io/gh/mie-lab/trackintel/pull/192?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [trackintel/model/locations.py](https://codecov.io/gh/mie-lab/trackintel/pull/192/diff?src=pr&el=tree#diff-dHJhY2tpbnRlbC9tb2RlbC9sb2NhdGlvbnMucHk=) | `87.50% <ø> (+8.33%)` | :arrow_up: |
| [trackintel/model/staypoints.py](https://codecov.io/gh/mie-lab/trackintel/pull/192/diff?src=pr&el=tree#diff-dHJhY2tpbnRlbC9tb2RlbC9zdGF5cG9pbnRzLnB5) | `96.87% <ø> (+12.50%)` | :arrow_up: |
| [trackintel/model/tours.py](https://codecov.io/gh/mie-lab/trackintel/pull/192/diff?src=pr&el=tree#diff-dHJhY2tpbnRlbC9tb2RlbC90b3Vycy5weQ==) | `57.14% <ø> (ø)` | |
| [trackintel/model/trips.py](https://codecov.io/gh/mie-lab/trackintel/pull/192/diff?src=pr&el=tree#diff-dHJhY2tpbnRlbC9tb2RlbC90cmlwcy5weQ==) | `94.44% <ø> (+11.11%)` | :arrow_up: |
| [trackintel/model/users.py](https://codecov.io/gh/mie-lab/trackintel/pull/192/diff?src=pr&el=tree#diff-dHJhY2tpbnRlbC9tb2RlbC91c2Vycy5weQ==) | `100.00% <ø> (+33.33%)` | :arrow_up: |
| [trackintel/model/positionfixes.py](https://codecov.io/gh/mie-lab/trackintel/pull/192/diff?src=pr&el=tree#diff-dHJhY2tpbnRlbC9tb2RlbC9wb3NpdGlvbmZpeGVzLnB5) | `90.62% <100.00%> (+11.21%)` | :arrow_up: |
| [trackintel/model/triplegs.py](https://codecov.io/gh/mie-lab/trackintel/pull/192/diff?src=pr&el=tree#diff-dHJhY2tpbnRlbC9tb2RlbC90cmlwbGVncy5weQ==) | `96.96% <100.00%> (+12.12%)` | :arrow_up: |
| ... and [3 more](https://codecov.io/gh/mie-lab/trackintel/pull/192/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/mie-lab/trackintel/pull/192?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/mie-lab/trackintel/pull/192?src=pr&el=footer). Last update [948e105...226fb34](https://codecov.io/gh/mie-lab/trackintel/pull/192?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/docs/content/data_model_sql.rst b/docs/content/data_model_sql.rst
deleted file mode 100644
index 6eb1d77..0000000
--- a/docs/content/data_model_sql.rst
+++ /dev/null
@@ -1,213 +0,0 @@
-Data Model (SQL)
-****************
-
-For a general description of the data model, please refer to the 
-:doc:`/modules/model`. You can download the 
-`complete SQL script here <https://github.com/mie-lab/trackintel/blob/master/sql/create_tables_pg.sql>`_ 
-in case you want to quickly set up a database. Also take a look at the `example on github 
-<https://github.com/mie-lab/trackintel/blob/master/examples/setup_example_database.py>`_.
-
-.. 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 trip leg or a staypoint::
-
-    CREATE TABLE positionfixes (
-        -- Common to all tables.
-        id bigint NOT NULL,
-        user_id bigint NOT NULL,
-
-        -- References to foreign tables.
-        tripleg_id bigint,
-        staypoint_id bigint,
-
-        -- Temporal attributes.
-        tracked_at timestamp without time zone NOT NULL,
-
-        -- Specific attributes.
-        accuracy double precision,
-        tracking_tech character(12),
-        -- The context contains additional information that might be filled in by trackintel.
-        -- This could include things such as the temperature, public transport stops in vicinity, etc.
-        context json,
-
-        -- Spatial attributes.
-        elevation double precision,
-        geom geometry(Point, 4326),
-
-        -- Constraints.
-        CONSTRAINT positionfixes_pkey PRIMARY KEY (id)
-    );
-
-The **staypoints** table contains all stay points, i.e., points where a user stayed
-for a certain amount of time. They are linked to a user, as well as (potentially) to a trip
-and location. Depending on the purpose and time spent, a staypoint can be an *activity*,
-i.e., a meaningful destination of movement::
-
-    CREATE TABLE staypoints (
-        -- Common to all tables.
-        id bigint NOT NULL,
-        user_id bigint NOT NULL,
-
-        -- References to foreign tables.
-        trip_id bigint,
-        location_id bigint,
-
-        -- Temporal attributes.
-        started_at timestamp without time zone NOT NULL,
-        finished_at timestamp without time zone NOT NULL,
-        
-        -- Attributes related to the activity performed at the staypoint.
-        purpose_detected character varying,
-        purpose_validated character varying,
-        validated boolean,
-        validated_at timestamp without time zone,
-        activity boolean,
-
-        -- Specific attributes.
-        -- The radius is an approximation of how far the positionfixes that made up this staypoint
-        -- are scattered around the center (geom) of it.
-        radius double precision,
-        -- The context contains additional information that might be filled in by trackintel.
-        -- This could include things such as the temperature, public transport stops in vicinity, etc.
-        context json,
-
-        -- Spatial attributes.
-        elevation double precision,
-        geom geometry(Point, 4326),
-
-        -- Constraints.
-        CONSTRAINT staypoints_pkey PRIMARY KEY (id)
-    );
-
-The **triplegs** table contains all trip legs, i.e., journeys that have been taken 
-with a single mode of transport. They are linked to both a user, as well as a trip 
-and if applicable, a public transport case::
-
-    CREATE TABLE triplegs (
-        -- Common to all tables.
-        id bigint NOT NULL,
-        user_id bigint NOT NULL,
-
-        -- References to foreign tables.
-        trip_id bigint,
-
-        -- Temporal attributes.
-        started_at timestamp without time zone NOT NULL,
-        finished_at timestamp without time zone NOT NULL,
-
-        -- Attributes related to the transport mode used for this trip leg.
-        mode_detected character varying,
-        mode_validated character varying,
-        validated boolean,
-        validated_at timestamp without time zone,
-
-        -- Specific attributes.
-        -- The context contains additional information that might be filled in by trackintel.
-        -- This could include things such as the temperature, public transport stops in vicinity, etc.
-        context json,
-
-        -- Spatial attributes.
-        -- The raw geometry is unprocessed, directly made up from the positionfixes. The column
-        -- 'geom' contains processed (e.g., smoothened, map matched, etc.) data.
-        geom_raw geometry(Linestring, 4326),
-        geom geometry(Linestring, 4326),
-
-        -- Constraints.
-        CONSTRAINT triplegs_pkey PRIMARY KEY (id)
-    );
-
-The **locations** table contains all locations, i.e., somehow created (e.g., from clustering
-staypoints) meaningful locations::
-
-    CREATE TABLE locations (
-        -- Common to all tables.
-        id bigint NOT NULL,
-        user_id bigint,
-
-        -- Specific attributes.
-        -- The context contains additional information that might be filled in by trackintel.
-        -- This could include things such as the temperature, public transport stops in vicinity, etc.
-        context json,
-        
-        -- Spatial attributes.
-        elevation double precision,
-        extent geometry(Polygon, 4326),
-        center geometry(Point, 4326),
-
-        -- Constraints.
-        CONSTRAINT locations_pkey PRIMARY KEY (id)
-    );
-
-The **trips** table contains all trips, i.e., collection of trip legs going from one 
-activity (staypoint with ``activity==True``) to another. They are simply linked to a user::
-
-    CREATE TABLE trips (
-        -- Common to all tables.
-        id bigint NOT NULL,
-        user_id integer NOT NULL,
-
-        -- References to foreign tables.
-        origin_staypoint_id bigint,
-        destination_staypoint_id bigint,
-
-        -- Temporal attributes.
-        started_at timestamp without time zone NOT NULL,
-        finished_at timestamp without time zone NOT NULL,
-        
-        -- Specific attributes.
-        -- The context contains additional information that might be filled in by trackintel.
-        -- This could include things such as the temperature, public transport stops in vicinity, etc.
-        context json,
-
-        -- Constraints.
-        CONSTRAINT trips_pkey PRIMARY KEY (id)
-    );
-
-The **tours** table contains all tours, i.e., sequence of trips which start and end 
-at the same location (in case of ``journey==True`` this location is *home*). 
-They are linked to a user::
-
-    CREATE TABLE tours (
-        -- Common to all tables.
-        id bigint NOT NULL,
-        user_id integer NOT NULL,
-
-        -- References to foreign tables.
-        origin_destination_location_id bigint,
-
-        -- Temporal attributes.
-        started_at timestamp without time zone NOT NULL,
-        finished_at timestamp without time zone NOT NULL,
-        
-        -- Specific attributes.
-        journey bool,
-        -- The context contains additional information that might be filled in by trackintel.
-        -- This could include things such as the temperature, public transport stops in vicinity, etc.
-        context json,
-
-        -- Constraints.
-        CONSTRAINT tours_pkey PRIMARY KEY (id)
-    );
diff --git a/docs/index.rst b/docs/index.rst
index 62e7f1a..0dab981 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -23,7 +23,7 @@ and assumes that data is available adhering to the trackintel data model format:
 
 For information about the trackintel data models that are used throughout the framework, 
 please refer to the :doc:`/modules/model` page. For a quick deployment to a PostGIS database, you can 
-use the SQL commands given at :doc:`/content/data_model_sql` or run the file found 
+use the SQL commands given at :ref:`data_model` or run the file found 
 `on Github <https://github.com/mie-lab/trackintel/blob/master/sql/create_tables_pg.sql>`_.
 
 .. toctree::
diff --git a/docs/modules/model.rst b/docs/modules/model.rst
index 2d7d882..9638bff 100644
--- a/docs/modules/model.rst
+++ b/docs/modules/model.rst
@@ -12,8 +12,8 @@ provides functionality to generate everything starting from the raw GPS position
 * **triplegs**: Segments covered with one mode of transport.
 * **locations**: Clustered staypoints.
 * **trips**: Segments between consecutive activity staypoints (special staypoints that are not just waiting points).
-* **tours**: Sequences of trips which start and end at the same location (if ``journey`` 
-  is set to ``True``, this location is *home*).
+* **tours**: Sequences of trips which start and end at the same location (if the column 'journey' 
+  is True, this location is *home*).
 
 An example plot showing the hierarchy of the trackintel data model can be found below:
 
@@ -33,11 +33,7 @@ The image below explicitly shows the definition of locations as clustered staypo
 	
 
 A detailed (and SQL-specific) explanation of the different classes can be found under 
-:doc:`/content/data_model_sql`.
-
-Some of the more time-consuming functions of trackintel generate logging data, as well as extracted 
-features data, and they assume more data about geographic features or characteristics of transport 
-modes are available. These are not explained here yet.
+:ref:`data_model`.
 
 GeoPandas Implementation
 ========================
@@ -49,11 +45,11 @@ do not extend the given DataFrame constructs, we provide accessors that validate
 corresponds to a set of constraints, and make functions available on the DataFrames. For example::
 
     df = trackintel.read_positionfixes_csv('data.csv')
-    df.as_positionfixes.extract_staypoints()
+    df.as_positionfixes.generate_staypoints()
 
 This will read a CSV into a format compatible with the trackintel understanding of a collection of 
 positionfixes, and the second line will wrap the DataFrame with an accessor providing functions such 
-as ``extract_staypoints()``. You can read up more on Pandas accessors in `the Pandas documentation 
+as ``generate_staypoints()``. You can read up more on Pandas accessors in `the Pandas documentation 
 <https://pandas.pydata.org/pandas-docs/stable/development/extending.html>`_.
 
 Available Accessors
@@ -81,3 +77,221 @@ The following accessors are available within *trackintel*.
 
 .. autoclass:: trackintel.model.tours.ToursAccessor
 	:members:
+
+
+.. _data_model:
+
+Data Model (SQL)
+================
+
+
+For a general description of the data model, please refer to the 
+:doc:`/modules/model`. You can download the 
+complete SQL script `here <https://github.com/mie-lab/trackintel/blob/master/sql/create_tables_pg.sql>`_ 
+in case you want to quickly set up a database. Also take a look at the `example on github 
+<https://github.com/mie-lab/trackintel/blob/master/examples/setup_example_database.py>`_.
+
+.. 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::
+
+    CREATE TABLE positionfixes (
+        -- Common to all tables.
+        id bigint NOT NULL,
+        user_id bigint NOT NULL,
+
+        -- References to foreign tables.
+        tripleg_id bigint,
+        staypoint_id bigint,
+
+        -- Temporal attributes.
+        tracked_at timestamp with time zone NOT NULL,
+
+        -- Specific attributes.
+        accuracy double precision,
+        tracking_tech character(12),
+        -- The context contains additional information that might be filled in by trackintel.
+        -- This could include things such as the temperature, public transport stops in vicinity, etc.
+        context json,
+
+        -- Spatial attributes.
+        elevation double precision,
+        geom geometry(Point, 4326),
+
+        -- Constraints.
+        CONSTRAINT positionfixes_pkey PRIMARY KEY (id)
+    );
+
+The **staypoints** table contains all stay points, i.e., points where a user stayed
+for a certain amount of time. They are linked to a user, as well as (potentially) to a trip
+and location. Depending on the purpose and time spent, a staypoint can be an *activity*,
+i.e., a meaningful destination of movement::
+
+    CREATE TABLE staypoints (
+        -- Common to all tables.
+        id bigint NOT NULL,
+        user_id bigint NOT NULL,
+
+        -- References to foreign tables.
+        trip_id bigint,
+        location_id bigint,
+
+        -- Temporal attributes.
+        started_at timestamp with time zone NOT NULL,
+        finished_at timestamp with time zone NOT NULL,
+        
+        -- Attributes related to the activity performed at the staypoint.
+        purpose_detected character varying,
+        purpose_validated character varying,
+        validated boolean,
+        validated_at timestamp with time zone,
+        activity boolean,
+
+        -- Specific attributes.
+        -- The radius is an approximation of how far the positionfixes that made up this staypoint
+        -- are scattered around the center (geom) of it.
+        radius double precision,
+        -- The context contains additional information that might be filled in by trackintel.
+        -- This could include things such as the temperature, public transport stops in vicinity, etc.
+        context json,
+
+        -- Spatial attributes.
+        elevation double precision,
+        geom geometry(Point, 4326),
+
+        -- Constraints.
+        CONSTRAINT staypoints_pkey PRIMARY KEY (id)
+    );
+
+The **triplegs** table contains all triplegs, i.e., journeys that have been taken 
+with a single mode of transport. They are linked to both a user, as well as a trip 
+and if applicable, a public transport case::
+
+    CREATE TABLE triplegs (
+        -- Common to all tables.
+        id bigint NOT NULL,
+        user_id bigint NOT NULL,
+
+        -- References to foreign tables.
+        trip_id bigint,
+
+        -- Temporal attributes.
+        started_at timestamp with time zone NOT NULL,
+        finished_at timestamp with time zone NOT NULL,
+
+        -- Attributes related to the transport mode used for this tripleg.
+        mode_detected character varying,
+        mode_validated character varying,
+        validated boolean,
+        validated_at timestamp with time zone,
+
+        -- Specific attributes.
+        -- The context contains additional information that might be filled in by trackintel.
+        -- This could include things such as the temperature, public transport stops in vicinity, etc.
+        context json,
+
+        -- Spatial attributes.
+        -- The raw geometry is unprocessed, directly made up from the positionfixes. The column
+        -- 'geom' contains processed (e.g., smoothened, map matched, etc.) data.
+        geom_raw geometry(Linestring, 4326),
+        geom geometry(Linestring, 4326),
+
+        -- Constraints.
+        CONSTRAINT triplegs_pkey PRIMARY KEY (id)
+    );
+
+The **locations** table contains all locations, i.e., somehow created (e.g., from clustering
+staypoints) meaningful locations::
+
+    CREATE TABLE locations (
+        -- Common to all tables.
+        id bigint NOT NULL,
+        user_id bigint,
+
+        -- Specific attributes.
+        -- The context contains additional information that might be filled in by trackintel.
+        -- This could include things such as the temperature, public transport stops in vicinity, etc.
+        context json,
+        
+        -- Spatial attributes.
+        elevation double precision,
+        extent geometry(Polygon, 4326),
+        center geometry(Point, 4326),
+
+        -- Constraints.
+        CONSTRAINT locations_pkey PRIMARY KEY (id)
+    );
+
+The **trips** table contains all trips, i.e., collection of trip legs going from one 
+activity (staypoint with ``activity==True``) to another. They are simply linked to a user::
+
+    CREATE TABLE trips (
+        -- Common to all tables.
+        id bigint NOT NULL,
+        user_id integer NOT NULL,
+
+        -- References to foreign tables.
+        origin_staypoint_id bigint,
+        destination_staypoint_id bigint,
+
+        -- Temporal attributes.
+        started_at timestamp with time zone NOT NULL,
+        finished_at timestamp with time zone NOT NULL,
+        
+        -- Specific attributes.
+        -- The context contains additional information that might be filled in by trackintel.
+        -- This could include things such as the temperature, public transport stops in vicinity, etc.
+        context json,
+
+        -- Constraints.
+        CONSTRAINT trips_pkey PRIMARY KEY (id)
+    );
+
+The **tours** table contains all tours, i.e., sequence of trips which start and end 
+at the same location (in case of ``journey==True`` this location is *home*). 
+They are linked to a user::
+
+    CREATE TABLE tours (
+        -- Common to all tables.
+        id bigint NOT NULL,
+        user_id integer NOT NULL,
+
+        -- References to foreign tables.
+        origin_destination_location_id bigint,
+
+        -- Temporal attributes.
+        started_at timestamp with time zone NOT NULL,
+        finished_at timestamp with time zone NOT NULL,
+        
+        -- Specific attributes.
+        journey bool,
+        -- The context contains additional information that might be filled in by trackintel.
+        -- This could include things such as the temperature, public transport stops in vicinity, etc.
+        context json,
+
+        -- Constraints.
+        CONSTRAINT tours_pkey PRIMARY KEY (id)
+    );
diff --git a/trackintel/model/locations.py b/trackintel/model/locations.py
index abcc2aa..9f6f13c 100644
--- a/trackintel/model/locations.py
+++ b/trackintel/model/locations.py
@@ -8,16 +8,21 @@ import trackintel.visualization.staypoints
 
 @pd.api.extensions.register_dataframe_accessor("as_locations")
 class LocationsAccessor(object):
-    """A pandas accessor to treat (Geo)DataFrames as collections of locations. This
-    will define certain methods and accessors, as well as make sure that the DataFrame
+    """A pandas accessor to treat (Geo)DataFrames as collections of locations.
+    
+    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: 
-    ``['user_id', 'center']``
+    ['user_id', 'center']
 
     For several usecases, the following additional columns are required:
-    ``['elevation', 'context', 'extent']``
-
+    ['elevation', 'context', 'extent']
+    
+    Notes
+    -----
+    `Locations` are spatially aggregated `Staypoints` where a user frequently visits.
+    
     Examples
     --------
     >>> df.as_locations.plot()
@@ -42,23 +47,35 @@ class LocationsAccessor(object):
             raise AttributeError("The center geometry must be a Point (only first checked).")
 
     def plot(self, *args, **kwargs):
-        """Plots this collection of locations. 
-        See :func:`trackintel.visualization.locations.plot_locations`."""
+        """
+        Plot this collection of locations.
+        
+        See :func:`trackintel.visualization.locations.plot_center_of_locations`.
+        """
         ti.visualization.locations.plot_center_of_locations(self._obj, *args, **kwargs)
 
     def to_csv(self, filename, *args, **kwargs):
-        """Stores this collection of locations as a CSV file.
-        See :func:`trackintel.io.file.write_locations_csv`."""
+        """
+        Store this collection of locations as a CSV file.
+        
+        See :func:`trackintel.io.file.write_locations_csv`.
+        """
         ti.io.file.write_locations_csv(self._obj, filename, *args, **kwargs)
 
     def to_postgis(self, conn_string, table_name, schema=None,
             sql_chunksize=None, if_exists='replace'):
-        """Stores this collection of locations to PostGIS.
-        See :func:`trackintel.io.postgis.write_locations_postgis`."""
+        """
+        Store this collection of locations to PostGIS.
+        
+        See :func:`trackintel.io.postgis.write_locations_postgis`.
+        """
         ti.io.postgis.write_locations_postgis(self._obj, conn_string, table_name, 
             schema, sql_chunksize, if_exists)
         
     def spatial_filter(self, *args, **kwargs):
-        """Filter locations with a geo extent.
-        See :func:`trackintel.preprocessing.filter.spatial_filter`."""
+        """
+        Filter locations with a geo extent.
+        
+        See :func:`trackintel.preprocessing.filter.spatial_filter`.
+        """
         return ti.preprocessing.filter.spatial_filter(self._obj, *args, **kwargs)
\ No newline at end of file
diff --git a/trackintel/model/positionfixes.py b/trackintel/model/positionfixes.py
index 9d8bf05..b233e68 100644
--- a/trackintel/model/positionfixes.py
+++ b/trackintel/model/positionfixes.py
@@ -5,31 +5,32 @@ import trackintel as ti
 
 @pd.api.extensions.register_dataframe_accessor("as_positionfixes")
 class PositionfixesAccessor(object):
-    """A pandas accessor to treat (Geo)DataFrames as collections of positionfixes. This
-    will define certain methods and accessors, as well as make sure that the DataFrame
+    """A pandas accessor to treat (Geo)DataFrames as collections of `Positionfixes`.
+    
+    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: 
-    ``['user_id', 'tracked_at']``
+    ['user_id', 'tracked_at']
 
-    Requires valid ``point geometries``; the ``index`` of the GeoDataFrame will be treated as unique identifier
-    of the `Positionfixes`
+    Requires valid point geometries; the 'index' of the GeoDataFrame will be treated as unique identifier
+    of the `Positionfixes`.
 
     For several usecases, the following additional columns are required:
-    ``['elevation', 'accuracy', 'tracking_tech', 'context', 'staypoint_id', 'tripleg_id']``
+    ['elevation', 'accuracy', 'tracking_tech', 'context', 'staypoint_id', 'tripleg_id']
 
     Notes
-    -------
+    -----
     In GPS based movement data analysis `Positionfixes` are the smallest unit of tracking and
     represent timestamped locations.
 
-    ``tracked_at`` is a timezone aware pandas datetime object.
+    'tracked_at' is a timezone aware pandas datetime object.
 
     Examples
     --------
     >>> df.as_positionfixes.generate_staypoints()
     """
-
+    
     required_columns = ['user_id', 'tracked_at']
 
     def __init__(self, pandas_obj):
@@ -58,54 +59,57 @@ class PositionfixesAccessor(object):
 
     @property
     def center(self):
-        """Returns the center coordinate of this collection of positionfixes."""
+        """Return the center coordinate of this collection of positionfixes."""
         lat = self._obj.geometry.y
         lon = self._obj.geometry.x
         return (float(lon.mean()), float(lat.mean()))
 
     def generate_staypoints(self, *args, **kwargs):
-        """Generates staypoints from this collection of positionfixes. 
-        See :func:`trackintel.preprocessing.positionfixes.generate_staypoints`."""
+        """
+        Generate staypoints from this collection of positionfixes.
+        
+        See :func:`trackintel.preprocessing.positionfixes.generate_staypoints`.
+        """
         return ti.preprocessing.positionfixes.generate_staypoints(self._obj, *args, **kwargs)
 
     def generate_triplegs(self, staypoints=None, *args, **kwargs):
-        """Generates triplegs from this collection of positionfixes.
+        """
+        Generate triplegs from this collection of positionfixes.
+        
         See :func:`trackintel.preprocessing.positionfixes.generate_triplegs`.
         """
         return ti.preprocessing.positionfixes.generate_triplegs(self._obj, staypoints, *args, **kwargs)
-
-    def generate_staypoints_and_triplegs(self, *args, **kwargs):
-        """Generates staypoints, uses them to build triplegs, and builds all associations 
-        with the original positionfixes (i.e., returning everything in accordance with the trackintel
-        :doc:`/content/data_model_sql`).
+    
+    def plot(self, *args, **kwargs):
+        """
+        Plot this collection of positionfixes.
         
-        Might never be implemented as you can just manually first call ``extract_staypoints`` and then
-        ``extract_triplegs``.
-
-        Returns
-        -------
-        tuple
-            A tuple consisting of (positionfixes, staypoints, triplegs).
+        See :func:`trackintel.visualization.positionfixes.plot_positionfixes`.
         """
-        return NotImplementedError
-
-    def plot(self, *args, **kwargs):
-        """Plots this collection of positionfixes. 
-        See :func:`trackintel.visualization.positionfixes.plot_positionfixes`."""
         ti.visualization.positionfixes.plot_positionfixes(self._obj, *args, **kwargs)
 
     def to_csv(self, filename, *args, **kwargs):
-        """Stores this collection of trackpoints as a CSV file.
-        See :func:`trackintel.io.file.write_positionfixes_csv`."""
+        """
+        Store this collection of trackpoints as a CSV file.
+        
+        See :func:`trackintel.io.file.write_positionfixes_csv`.
+        """
         ti.io.file.write_positionfixes_csv(self._obj, filename, *args, **kwargs)
 
     def to_postgis(self, conn_string, table_name, schema=None,
                    sql_chunksize=None, if_exists='replace'):
-        """Stores this collection of positionfixes to PostGIS.
-        See :func:`trackintel.io.postgis.write_positionfixes_postgis`."""
+        """
+        Store this collection of positionfixes to PostGIS.
+        
+        See :func:`trackintel.io.postgis.write_positionfixes_postgis`.
+        """
         ti.io.postgis.write_positionfixes_postgis(self._obj, conn_string, table_name,
                                                   schema, sql_chunksize, if_exists)
 
-    def similarity_matrix(self, method, field='tripleg_id', trsh=None, eps=None, dist=False, **kwargs):
-        """Calculates Similarity (/distance) matrix. See: func: 'trackintel.similarity.detection.similarity_matrix' """
-        return ti.similarity.similarity_matrix(self._obj, method, field, trsh, eps, dist, **kwargs)
+    def calculate_distance_matrix(self, *args, **kwargs):
+        """
+        Calculate pair-wise distance among positionfixes or to other positionfixes.
+        
+        See :func:'trackintel.geogr.distances.calculate_distance_matrix'.
+        """
+        return ti.geogr.distances.calculate_distance_matrix(self._obj, *args, **kwargs)
diff --git a/trackintel/model/staypoints.py b/trackintel/model/staypoints.py
index f1cf93b..0141860 100644
--- a/trackintel/model/staypoints.py
+++ b/trackintel/model/staypoints.py
@@ -5,27 +5,29 @@ import trackintel as ti
 
 @pd.api.extensions.register_dataframe_accessor("as_staypoints")
 class StaypointsAccessor(object):
-    """A pandas accessor to treat (Geo)DataFrames as collections of staypoints. This
-    will define certain methods and accessors, as well as make sure that the DataFrame
+    """A pandas accessor to treat (Geo)DataFrames as collections of `Staypoints`.
+    
+    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: 
-    ``['user_id', 'started_at', 'finished_at']``
+    ['user_id', 'started_at', 'finished_at']
 
-    Requires valid ``point geometries``; the ``index`` of the GeoDataFrame will be treated as unique identifier
-    of the `Staypoints`
+    Requires valid point geometries; the 'index' of the GeoDataFrame will be treated as unique identifier
+    of the `Staypoints`.
 
     For several usecases, the following additional columns are required:
-    ``['elevation', 'radius', 'context', 'purpose', 'activity', 'next_trip_id', 'prev_trip_id', 'trip_id',
-    location_id]``
+    ['elevation', 'radius', 'context', 'purpose', 'activity', 'next_trip_id', 'prev_trip_id', 'trip_id',
+    location_id]
 
     Notes
-    -------
-    Staypoints are defined as location were a person did not move for a while. Under consideration of location
-    uncertainty this means that a person stays within a certain radius for a certain amount of time.
+    -----
+    `Staypoints` are defined as location were a person did not move for a while. 
+    Under consideration of location uncertainty this means that a person stays within 
+    a certain radius for a certain amount of time.
     The exact definition is use-case dependent.
 
-    ``started_at`` and ``finished_at`` are timezone aware pandas datetime objects.
+    'started_at' and 'finished_at' are timezone aware pandas datetime objects.
 
     Examples
     --------
@@ -50,7 +52,7 @@ class StaypointsAccessor(object):
                                             "where x is you GeoDataFrame"
         if obj.geometry.iloc[0].geom_type != 'Point':
             raise AttributeError("The geometry must be a Point (only first checked).")
-
+        
         # check timestamp dtypes
         assert pd.api.types.is_datetime64tz_dtype(obj['started_at']), \
             "dtype of started_at is {} but has to be tz aware datetime64".format(obj['started_at'].dtype)
@@ -59,37 +61,55 @@ class StaypointsAccessor(object):
 
     @property
     def center(self):
-        """Returns the center coordinate of this collection of staypoints."""
+        """Return the center coordinate of this collection of staypoints."""
         lat = self._obj.geometry.y
         lon = self._obj.geometry.x
         return (float(lon.mean()), float(lat.mean()))
 
     def generate_locations(self, *args, **kwargs):
-        """Generate locations from this collection of staypoints.
-        See :func:`trackintel.preprocessing.staypoints.generate_locations`."""
+        """
+        Generate locations from this collection of staypoints.
+        
+        See :func:`trackintel.preprocessing.staypoints.generate_locations`.
+        """
         return ti.preprocessing.staypoints.generate_locations(self._obj, *args, **kwargs)
 
     def create_activity_flag(self, *args, **kwargs):
-        """Sets a flag if a staypoint is also an activity.
-        See :func:`trackintel.preprocessing.staypoints.create_activity_flag`."""
+        """
+        Set a flag if a staypoint is also an activity.
+        
+        See :func:`trackintel.preprocessing.staypoints.create_activity_flag`.
+        """
         return ti.preprocessing.staypoints.create_activity_flag(self._obj, *args, **kwargs)
 
     def spatial_filter(self, *args, **kwargs):
-        """Filter staypoints with a geo extent.
-        See :func:`trackintel.preprocessing.filter.spatial_filter`."""
+        """
+        Filter staypoints with a geo extent.
+        
+        See :func:`trackintel.preprocessing.filter.spatial_filter`.
+        """
         return ti.preprocessing.filter.spatial_filter(self._obj, *args, **kwargs)
 
     def plot(self, *args, **kwargs):
-        """Plots this collection of staypoints. 
-        See :func:`trackintel.visualization.staypoints.plot_staypoints`."""
+        """
+        Plot this collection of staypoints.
+        
+        See :func:`trackintel.visualization.staypoints.plot_staypoints`.
+        """
         ti.visualization.staypoints.plot_staypoints(self._obj, *args, **kwargs)
 
     def to_csv(self, filename, *args, **kwargs):
-        """Stores this collection of staypoints as a CSV file.
-        See :func:`trackintel.io.file.write_staypoints_csv`."""
+        """
+        Store this collection of staypoints as a CSV file.
+        
+        See :func:`trackintel.io.file.write_staypoints_csv`.
+        """
         ti.io.file.write_staypoints_csv(self._obj, filename, *args, **kwargs)
 
     def to_postgis(self, conn_string, table_name):
-        """Stores this collection of staypoints to PostGIS.
-        See :func:`trackintel.io.postgis.write_staypoints_postgis`."""
+        """
+        Store this collection of staypoints to PostGIS.
+        
+        See :func:`trackintel.io.postgis.write_staypoints_postgis`.
+        """
         ti.io.postgis.write_staypoints_postgis(self._obj, conn_string, table_name)
diff --git a/trackintel/model/tours.py b/trackintel/model/tours.py
index 3e06beb..558b1e0 100644
--- a/trackintel/model/tours.py
+++ b/trackintel/model/tours.py
@@ -3,22 +3,22 @@ import pandas as pd
 
 @pd.api.extensions.register_dataframe_accessor("as_tours")
 class ToursAccessor(object):
-    """A pandas accessor to treat DataFrames as collections of tours. 
+    """A pandas accessor to treat DataFrames as collections of `Tours`.
 
     Requires at least the following columns: 
-    ``['user_id', 'started_at', 'finished_at', 'origin_staypoint_id', 'journey']``
+    ['user_id', 'started_at', 'finished_at', 'origin_staypoint_id', 'journey']
 
-    The ``index`` of the GeoDataFrame will be treated as unique identifier of the `trips`
+    The 'index' of the GeoDataFrame will be treated as unique identifier of the `Tours`
 
     For several usecases, the following additional columns are required:
-    ``['context']``
+    ['context']
 
     Notes
-    --------
+    -----
     Tours are an aggregation level in transport planning that summarize all trips until a person returns to the
     same location. Tours starting and ending at home (=journey) are especially important.
 
-    ``started_at`` and ``finished_at`` are timezone aware pandas datetime objects.
+    'started_at' and 'finished_at' are timezone aware pandas datetime objects.
 
     Examples
     --------
@@ -45,11 +45,17 @@ class ToursAccessor(object):
             "dtype of finished_at is {} but has to be datetime64 and timezone aware".format(obj['finished_at'].dtype)
 
     def to_csv(self, filename, *args, **kwargs):
-        """Stores this collection of tours as a CSV file.
-        See :func:`trackintel.io.file.write_tours_csv`."""
+        """
+        Store this collection of tours as a CSV file.
+        
+        See :func:`trackintel.io.file.write_tours_csv`.
+        """
         raise NotImplementedError
 
     def plot(self, *args, **kwargs):
-        """Plots this collection of tours. 
-        See :func:`trackintel.visualization.tours.plot_tours`."""
+        """
+        Plot this collection of tours.
+        
+        See :func:`trackintel.visualization.tours.plot_tours`.
+        """
         raise NotImplementedError
diff --git a/trackintel/model/triplegs.py b/trackintel/model/triplegs.py
index c546801..fb4e771 100644
--- a/trackintel/model/triplegs.py
+++ b/trackintel/model/triplegs.py
@@ -7,24 +7,25 @@ import trackintel.visualization.triplegs
 
 @pd.api.extensions.register_dataframe_accessor("as_triplegs")
 class TriplegsAccessor(object):
-    """A pandas accessor to treat (Geo)DataFrames as collections of triplegs. This
-    will define certain methods and accessors, as well as make sure that the DataFrame
+    """A pandas accessor to treat (Geo)DataFrames as collections of `Tripleg`.
+    
+    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: 
-    ``['user_id', 'started_at', 'finished_at']``
+    ['user_id', 'started_at', 'finished_at']
 
-    Requires valid ``line geometries``; the ``index`` of the GeoDataFrame will be treated as unique identifier
+    Requires valid line geometries; the 'index' of the GeoDataFrame will be treated as unique identifier
     of the `triplegs`
 
     For several usecases, the following additional columns are required:
-    ``['mode', 'trip_id']``
+    ['mode', 'trip_id']
 
     Notes
-    -------
-    A `tripleg` (also called `stage`) is defined as continuous movement without changing the mode of transport.
+    -----
+    A `Tripleg` (also called `stage`) is defined as continuous movement without changing the mode of transport.
 
-    ``started_at`` and ``finished_at`` are timezone aware pandas datetime objects.
+    'started_at' and 'finished_at' are timezone aware pandas datetime objects.
 
     Examples
     --------
@@ -58,39 +59,57 @@ class TriplegsAccessor(object):
             "dtype of finished_at is {} but has to be datetime64 and timezone aware".format(obj['finished_at'].dtype)
 
     def plot(self, *args, **kwargs):
-        """Plots this collection of triplegs. 
-        See :func:`trackintel.visualization.triplegs.plot_triplegs`."""
+        """
+        Plot this collection of triplegs.
+         
+        See :func:`trackintel.visualization.triplegs.plot_triplegs`.
+        """
         ti.visualization.triplegs.plot_triplegs(self._obj, *args, **kwargs)
 
     def to_csv(self, filename, *args, **kwargs):
-        """Stores this collection of triplegs as a CSV file.
-        See :func:`trackintel.io.file.write_triplegs_csv`."""
+        """
+        Store this collection of triplegs as a CSV file.
+        
+        See :func:`trackintel.io.file.write_triplegs_csv`.
+        """
         ti.io.file.write_triplegs_csv(self._obj, filename, *args, **kwargs)
 
     def to_postgis(self, conn_string, table_name):
-        """Stores this collection of triplegs to PostGIS.
-        See :func:`trackintel.io.postgis.store_positionfixes_postgis`."""
+        """
+        Store this collection of triplegs to PostGIS.
+        
+        See :func:`trackintel.io.postgis.store_positionfixes_postgis`.
+        """
         ti.io.postgis.write_triplegs_postgis(self._obj, conn_string, table_name)
 
-    def similarity(self, *args, **kwargs):
-        """Calculate pair-wise distance among triplegs (x) or to other triplegs (y)
+    def calculate_distance_matrix(self, *args, **kwargs):
+        """
+        Calculate pair-wise distance among triplegs or to other triplegs.
+        
         See :func:`trackintel.geogr.distances.calculate_distance_matrix`.
         """
         return ti.geogr.distances.calculate_distance_matrix(self._obj, *args, **kwargs)
 
     def spatial_filter(self, *args, **kwargs):
-        """Filter triplegs with a geo extent.
-        See :func:`trackintel.preprocessing.filter.spatial_filter`."""
+        """
+        Filter triplegs with a geo extent.
+        
+        See :func:`trackintel.preprocessing.filter.spatial_filter`.
+        """
         return ti.preprocessing.filter.spatial_filter(self._obj, *args, **kwargs)
 
     def predict_transport_mode(self, *args, **kwargs):
-        """Predict/impute the transport mode with which each tripleg was likely covered.
+        """
+        Predict/impute the transport mode with which each tripleg was likely covered.
+        
         See :func:`trackintel.analysis.transport_mode_identification.predict_transport_mode`.
         """
         return ti.analysis.transport_mode_identification.predict_transport_mode(self._obj, *args, **kwargs)
 
     def calculate_modal_split(self, *args, **kwargs):
-        """Calculates the modal split of the triplegs.
+        """
+        Calculate the modal split of the triplegs.
+        
         See :func:`trackintel.analysis.modal_split.calculate_modal_split`.
         """
         return ti.analysis.modal_split.calculate_modal_split(self._obj, *args, **kwargs)
diff --git a/trackintel/model/trips.py b/trackintel/model/trips.py
index ed1cec7..62d9bd9 100644
--- a/trackintel/model/trips.py
+++ b/trackintel/model/trips.py
@@ -11,36 +11,33 @@ class TripsAccessor(object):
     adheres to some requirements.
 
     Requires at least the following columns: 
-    ``['user_id', 'started_at', 'finished_at', 'origin_staypoint_id', 'destination_staypoint_id']``
+    ['user_id', 'started_at', 'finished_at', 'origin_staypoint_id', 'destination_staypoint_id']
 
-    The ``index`` of the GeoDataFrame will be treated as unique identifier of the `trips`
+    The 'index' of the GeoDataFrame will be treated as unique identifier of the `Trips`
 
     For several usecases, the following additional columns are required:
-    ``['context', 'origin_activity', 'destination_activity', 'modes', 'primary_mode', 'tour_id']``
+    ['context', 'origin_activity', 'destination_activity', 'modes', 'primary_mode', 'tour_id']
 
     Notes
     -----
-    Trips are an aggregation level in transport planning that summarize all movement and all non-essential actions
+    `Trips` are an aggregation level in transport planning that summarize all movement and all non-essential actions
     (e.g., waiting) between two relevant activities.
-    The function returns altered versions of the input staypoints and triplegs. Staypoints receive the fields
-    [`trip_id` `prev_trip_id` and `next_trip_id`], triplegs receive the field [`trip_id`].
+
     The following assumptions are implemented
     
         - All movement before the first and after the last activity is omitted
         - If we do not record a person for more than `gap_threshold` minutes, we assume that the person performed an \
             activity in the recording gap and split the trip at the gap.
-        - Trips that start/end in a recording gap can have an unknown origin/destination
+        - Trips that start/end in a recording gap can have an unknown origin/destination.
         - There are no trips without a (recored) tripleg.
         
-    ``started_at`` and ``finished_at`` are timezone aware pandas datetime objects.
+    'started_at' and 'finished_at' are timezone aware pandas datetime objects.
 
     Examples
     --------
     >>> df.as_trips.plot()
     """
 
-    # ToDo primary mode of transport
-
     required_columns = ['user_id', 'started_at', 'finished_at', 'origin_staypoint_id', 'destination_staypoint_id']
 
     def __init__(self, pandas_obj):
@@ -61,18 +58,27 @@ class TripsAccessor(object):
             "dtype of finished_at is {} but has to be datetime64 and timezone aware".format(obj['finished_at'].dtype)
 
     def plot(self, *args, **kwargs):
-        """Plots this collection of trips. 
-        See :func:`trackintel.visualization.trips.plot_trips`."""
+        """
+        Plot this collection of trips. 
+        
+        See :func:`trackintel.visualization.trips.plot_trips`.
+        """
         raise NotImplementedError
 
     def to_csv(self, filename, *args, **kwargs):
-        """Stores this collection of trips as a CSV file.
-        See :func:`trackintel.io.file.write_trips_csv`."""
+        """
+        Store this collection of trips as a CSV file.
+        
+        See :func:`trackintel.io.file.write_trips_csv`.
+        """
         ti.io.file.write_trips_csv(self._obj, filename, *args, **kwargs)
 
     def to_postgis(self, conn_string, table_name, schema=None,
                    sql_chunksize=None, if_exists='replace'):
-        """Stores this collection of trips to PostGIS.
-        See :func:`trackintel.io.postgis.write_trips_postgis`."""
+        """
+        Store this collection of trips to PostGIS.
+        
+        See :func:`trackintel.io.postgis.write_trips_postgis`.
+        """
         ti.io.postgis.write_trips_postgis(self._obj, conn_string, table_name,
                                           schema, sql_chunksize, if_exists)
diff --git a/trackintel/model/users.py b/trackintel/model/users.py
index d9a3121..edbcdc2 100644
--- a/trackintel/model/users.py
+++ b/trackintel/model/users.py
@@ -4,15 +4,16 @@ 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
+    """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']``
+    ['id']
 
     For several usecases, the following additional columns are required:
-    ``['attributes', 'geom_home', 'geom_work']``
+    ['attributes', 'geom_home', 'geom_work']
 
     Examples
     --------
@@ -33,6 +34,9 @@ class UsersAccessor(object):
                 % (', '.join(UsersAccessor.required_columns), ', '.join(obj.columns)))
 
     def plot_home_and_work(self):
-        """Plots home and work locations of users. 
-        See :func:`trackintel.visualization.users.plot_home_and_work`."""
+        """
+        Plot home and work locations of users.
+        
+        See :func:`trackintel.visualization.users.plot_home_and_work`.
+        """
         raise NotImplementedError


Test patch:
diff --git a/tests/geogr/test_distances.py b/tests/geogr/test_distances.py
index 689053a..7531e5d 100644
--- a/tests/geogr/test_distances.py
+++ b/tests/geogr/test_distances.py
@@ -125,8 +125,8 @@ class TestCalculate_distance_matrix:
         """Calculate Linestring length using dtw via accessor."""
         tpls = geolife_tpls 
 
-        D_single = tpls.iloc[0:4].as_triplegs.similarity(dist_metric='dtw', n_jobs=1)
-        D_multi = tpls.iloc[0:4].as_triplegs.similarity(dist_metric='dtw', n_jobs=4)
+        D_single = tpls.iloc[0:4].as_triplegs.calculate_distance_matrix(dist_metric='dtw', n_jobs=1)
+        D_multi = tpls.iloc[0:4].as_triplegs.calculate_distance_matrix(dist_metric='dtw', n_jobs=4)
 
         assert np.isclose(np.sum(np.abs(D_single - D_multi)), 0)
 
@@ -137,8 +137,8 @@ class TestCalculate_distance_matrix:
         x = tpls.iloc[0:2]
         y = tpls.iloc[4:8]
 
-        D_single = x.as_triplegs.similarity(Y=y, dist_metric='dtw', n_jobs=1)
-        D_multi = x.as_triplegs.similarity(Y=y, dist_metric='dtw', n_jobs=4)
+        D_single = x.as_triplegs.calculate_distance_matrix(Y=y, dist_metric='dtw', n_jobs=1)
+        D_multi = x.as_triplegs.calculate_distance_matrix(Y=y, dist_metric='dtw', n_jobs=4)
 
         assert np.isclose(np.sum(np.abs(D_single - D_multi)), 0)
         
@@ -147,9 +147,9 @@ class TestCalculate_distance_matrix:
         tpls = geolife_tpls
         
         with pytest.raises(AttributeError):
-            tpls.iloc[0:4].as_triplegs.similarity(dist_metric=12345, n_jobs=1)
+            tpls.iloc[0:4].as_triplegs.calculate_distance_matrix(dist_metric=12345, n_jobs=1)
         with pytest.raises(AttributeError):
-            tpls.iloc[0:4].as_triplegs.similarity(dist_metric="random", n_jobs=1)
+            tpls.iloc[0:4].as_triplegs.calculate_distance_matrix(dist_metric="random", n_jobs=1)
     
     def test_distance_error(self, single_linestring):
         """Test if the an error is raised when wrong geometry is passed."""
diff --git a/tests/model/__init__.py b/tests/model/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/model/test_locations.py b/tests/model/test_locations.py
new file mode 100644
index 0000000..673704e
--- /dev/null
+++ b/tests/model/test_locations.py
@@ -0,0 +1,38 @@
+
+import os
+import pytest
+
+from shapely.geometry import LineString
+
+import trackintel as ti
+
+
+@pytest.fixture
+def testdata_locs():
+    """Read location test data from files."""
+    stps_file = os.path.join('tests', 'data', 'geolife', 'geolife_staypoints.csv')
+    stps = ti.read_staypoints_csv(stps_file, tz='utc', index_col='id')
+    stps, locs = stps.as_staypoints.generate_locations(method='dbscan', 
+                                                        epsilon=10, 
+                                                        num_samples=0, 
+                                                        distance_matrix_metric='haversine',
+                                                        agg_level='dataset')
+    return locs
+
+
+class TestLocations:
+    """Tests for the LocationsAccessor."""
+    
+    def test_accessor_column(self, testdata_locs):
+        """Test if the as_locations accessor checks the required column for locations."""
+        locs = testdata_locs.copy()
+
+        with pytest.raises(AttributeError, match="To process a DataFrame as a collection of locations"):
+            locs.drop(['user_id'], axis=1).as_locations
+    
+    def test_accessor_geometry_type(self, testdata_locs):
+        """Test if the as_locations accessor requires Point geometry."""
+        locs = testdata_locs.copy()
+        with pytest.raises(AttributeError, match="The center geometry must be a Point"):
+            locs['center'] = LineString([(13.476808430, 48.573711823), (13.506804, 48.939008), (13.4664690, 48.5706414)])
+            locs.as_locations
\ No newline at end of file
diff --git a/tests/model/test_positionfixes.py b/tests/model/test_positionfixes.py
index cd7818b..3806f36 100644
--- a/tests/model/test_positionfixes.py
+++ b/tests/model/test_positionfixes.py
@@ -1,21 +1,58 @@
 import os
 import pytest
+import numpy as np
+
+from shapely.geometry import LineString
 
 import trackintel as ti
 
 
+@pytest.fixture
+def testdata_geolife():
+    """Read geolife test data from files."""
+    pfs, _ = ti.io.dataset_reader.read_geolife(os.path.join("tests", "data", "geolife"))
+    return pfs
 
 class TestPositionfixes:
-    def test_as_positionfixes_accessor(self):
-        pfs_file = os.path.join('tests', 'data', 'positionfixes.csv')
-        pfs = ti.read_positionfixes_csv(pfs_file, sep=';', index_col='id')
+    """Tests for the PositionfixesAccessor."""
+    
+    def test_accessor_column(self, testdata_geolife):
+        """Test if the as_positionfixes accessor checks the required column for positionfixes."""
+        pfs = testdata_geolife.copy()
         assert pfs.as_positionfixes
+            
+        # check user_id
+        with pytest.raises(AttributeError, match="To process a DataFrame as a collection of positionfixes"):
+            pfs.drop(['user_id'], axis=1).as_positionfixes
 
-        pfs = pfs.drop(['geom'], axis=1)
-        with pytest.raises(AttributeError):
+    
+    def test_accessor_geometry(self, testdata_geolife):
+        """Test if the as_positionfixes accessor requires geometry column."""
+        pfs = testdata_geolife.copy()
+        
+        # check geometry
+        with pytest.raises(AttributeError, match="No geometry data set yet"):
+            pfs.drop(['geom'], axis=1).as_positionfixes
+          
+    def test_accessor_geometry_type(self, testdata_geolife):
+        """Test if the as_positionfixes accessor requires Point geometry."""
+        pfs = testdata_geolife.copy()
+            
+        # check geometry type
+        with pytest.raises(AttributeError, match="The geometry must be a Point"):
+            pfs['geom'] = LineString([(13.476808430, 48.573711823), (13.506804, 48.939008), (13.4664690, 48.5706414)])
             pfs.as_positionfixes
 
-    def test_positionfixes_center(self):
-        pfs_file = os.path.join('tests', 'data', 'positionfixes.csv')
-        pfs = ti.read_positionfixes_csv(pfs_file, sep=';', index_col='id')
+
+    def test_center(self, testdata_geolife):
+        """Check if pfs has center method and returns (lat, lon) pairs as geometry."""
+        pfs = testdata_geolife
         assert len(pfs.as_positionfixes.center) == 2
+        
+    def test_similarity_matrix(self, testdata_geolife):
+        """Check the similarity_matrix function called through accessor runs as expected."""
+        pfs = testdata_geolife
+        
+        accessor_result = pfs.as_positionfixes.calculate_distance_matrix(dist_metric='haversine', n_jobs=1)
+        function_result = ti.geogr.distances.calculate_distance_matrix(pfs, dist_metric='haversine', n_jobs=1)
+        assert np.allclose(accessor_result, function_result)
diff --git a/tests/model/test_staypoints.py b/tests/model/test_staypoints.py
index 4c220af..6e81a82 100644
--- a/tests/model/test_staypoints.py
+++ b/tests/model/test_staypoints.py
@@ -1,23 +1,48 @@
 import os
 import pytest
+import numpy as np
+
+from shapely.geometry import LineString
 
 import trackintel as ti
 
 
+@pytest.fixture
+def testdata_stps():
+    """Read stps test data from files."""
+    stps_file = os.path.join('tests', 'data', 'staypoints.csv')
+    stps = ti.read_staypoints_csv(stps_file, sep=';', index_col='id')
+    return stps
 
 class TestStaypoints:
+    """Tests for the StaypointsAccessor."""
 
-    def test_as_staypoints_accessor(self):
-        stps_file = os.path.join('tests', 'data', 'staypoints.csv')
-        stps = ti.read_staypoints_csv(stps_file, sep=';', index_col='id')
+    def test_accessor_columns(self, testdata_stps):
+        """Test if the as_staypoints accessor checks the required column for staypoints."""
+        stps = testdata_stps.copy()
         assert stps.as_staypoints
-
-        stps = stps.drop(['geom'], axis=1)
-        with pytest.raises(AttributeError):
+        
+        with pytest.raises(AttributeError, match="To process a DataFrame as a collection of staypoints"):
+            stps.drop(['user_id'], axis=1).as_staypoints
+            
+    def test_accessor_geometry(self, testdata_stps):
+        """Test if the as_staypoints accessor requires geometry column."""
+        stps = testdata_stps.copy()
+        
+        # geometery
+        with pytest.raises(AttributeError, match="No geometry data set yet"):
+            stps.drop(['geom'], axis=1).as_staypoints
+            
+    def test_accessor_geometry_type(self, testdata_stps):
+        """Test if the as_staypoints accessor requires Point geometry."""
+        stps = testdata_stps.copy()
+        
+        # check geometry type
+        with pytest.raises(AttributeError, match="The geometry must be a Point"):
+            stps["geom"] = LineString([(13.476808430, 48.573711823), (13.506804, 48.939008), (13.4664690, 48.5706414)])
             stps.as_staypoints
 
-    def test_staypoints_center(self):
-        stps_file = os.path.join('tests', 'data', 'staypoints.csv')
-        stps = ti.read_staypoints_csv(stps_file, sep=';', index_col='id')
-        # check if stps has methods from gpd and contains (lat, lon) pairs as geometry
+    def test_staypoints_center(self, testdata_stps):
+        """Check if stps has center method and returns (lat, lon) pairs as geometry."""
+        stps = testdata_stps
         assert len(stps.as_staypoints.center) == 2
diff --git a/tests/model/test_triplegs.py b/tests/model/test_triplegs.py
new file mode 100644
index 0000000..c410504
--- /dev/null
+++ b/tests/model/test_triplegs.py
@@ -0,0 +1,46 @@
+import os
+import pytest
+
+from shapely.geometry import Point
+
+import trackintel as ti
+
+@pytest.fixture
+def testdata_tpls():
+    """Read triplegs test data from files."""
+    pfs, _ = ti.io.dataset_reader.read_geolife(os.path.join("tests", "data", "geolife"))
+    pfs, stps = pfs.as_positionfixes.generate_staypoints(method="sliding", dist_threshold=25, time_threshold=5 * 60)
+    _, tpls = pfs.as_positionfixes.generate_triplegs(stps, method="between_staypoints")
+        
+    return tpls
+
+
+class TestTriplegs:
+    """Tests for the TriplegsAccessor."""
+
+    def test_accessor_column(self, testdata_tpls):
+        """Test if the as_triplegs accessor checks the required column for triplegs."""
+        tpls = testdata_tpls.copy()
+        
+        assert tpls.as_triplegs
+            
+        # check user_id
+        with pytest.raises(AttributeError):
+            tpls.drop(['user_id'], axis=1).as_triplegs
+
+    def test_accessor_geometry(self, testdata_tpls):
+        """Test if the as_triplegs accessor requires geometry column."""
+        tpls = testdata_tpls.copy()
+        
+        # check geometry
+        with pytest.raises(AttributeError, match="No geometry data set yet"):
+            tpls.drop(['geom'], axis=1).as_triplegs
+            
+    def test_accessor_geometry_type(self, testdata_tpls):
+        """Test if the as_triplegs accessor requires LineString geometry."""
+        tpls = testdata_tpls.copy()
+            
+        # check geometry type
+        with pytest.raises(AttributeError, match="The geometry must be a LineString"):
+            tpls["geom"] = Point([(13.476808430, 48.573711823)])
+            tpls.as_triplegs
\ No newline at end of file
diff --git a/tests/model/test_trips.py b/tests/model/test_trips.py
new file mode 100644
index 0000000..9a78967
--- /dev/null
+++ b/tests/model/test_trips.py
@@ -0,0 +1,16 @@
+import os
+import pytest
+
+import trackintel as ti
+
+class TestTrips:
+    """Tests for the TripsAccessor."""
+
+    def test_accessor(self):
+        """Test if the as_trips accessor checks the required column for trips."""
+        trips = ti.read_trips_csv(os.path.join('tests', 'data', 'geolife_long', 'trips.csv'), index_col='id')
+        assert trips.as_trips
+            
+        # user_id
+        with pytest.raises(AttributeError):
+            trips.drop(['user_id'], axis=1).as_trips
diff --git a/tests/model/test_users.py b/tests/model/test_users.py
new file mode 100644
index 0000000..f657c2c
--- /dev/null
+++ b/tests/model/test_users.py
@@ -0,0 +1,20 @@
+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
\ No newline at end of file