Repository: mie-lab/trackintel

Issue:
tests (and test data) missing for (read) tours
function tours_from_gpd is not tested (#93) 
function read_tours_csv is not available. is this correct or should it be added?

Discussion:
bifbof: Is there a way to check which black version the lint-check uses?
codecov[bot]: # [Codecov](https://codecov.io/gh/mie-lab/trackintel/pull/348?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab) Report
> Merging [#348](https://codecov.io/gh/mie-lab/trackintel/pull/348?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab) (b699272) into [master](https://codecov.io/gh/mie-lab/trackintel/commit/5cd2b9a492984969dd6c8d8a6ca6dbd4b31e45ad?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab) (5cd2b9a) will **decrease** coverage by `2.18%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/mie-lab/trackintel/pull/348/graphs/tree.svg?width=650&height=150&src=pr&token=ITDZEEE1MO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab)](https://codecov.io/gh/mie-lab/trackintel/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab)

```diff
@@            Coverage Diff             @@
##           master     #348      +/-   ##
==========================================
- Coverage   96.41%   94.23%   -2.19%     
==========================================
  Files          40       40              
  Lines        1924     1924              
  Branches      313      312       -1     
==========================================
- Hits         1855     1813      -42     
- Misses         31       74      +43     
+ Partials       38       37       -1     
```


| [Impacted Files](https://codecov.io/gh/mie-lab/trackintel/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab) | Coverage Δ | |
|---|---|---|
| [trackintel/io/from\_geopandas.py](https://codecov.io/gh/mie-lab/trackintel/pull/348/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab#diff-dHJhY2tpbnRlbC9pby9mcm9tX2dlb3BhbmRhcy5weQ==) | `100.00% <100.00%> (+1.53%)` | :arrow_up: |
| [trackintel/io/postgis.py](https://codecov.io/gh/mie-lab/trackintel/pull/348/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab#diff-dHJhY2tpbnRlbC9pby9wb3N0Z2lzLnB5) | `49.36% <0.00%> (-48.11%)` | :arrow_down: |
| [trackintel/model/locations.py](https://codecov.io/gh/mie-lab/trackintel/pull/348/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab#diff-dHJhY2tpbnRlbC9tb2RlbC9sb2NhdGlvbnMucHk=) | `96.87% <0.00%> (-3.13%)` | :arrow_down: |
| [trackintel/model/trips.py](https://codecov.io/gh/mie-lab/trackintel/pull/348/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab#diff-dHJhY2tpbnRlbC9tb2RlbC90cmlwcy5weQ==) | `97.22% <0.00%> (-2.78%)` | :arrow_down: |
| [trackintel/model/positionfixes.py](https://codecov.io/gh/mie-lab/trackintel/pull/348/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab#diff-dHJhY2tpbnRlbC9tb2RlbC9wb3NpdGlvbmZpeGVzLnB5) | `97.82% <0.00%> (-2.18%)` | :arrow_down: |
| [trackintel/model/staypoints.py](https://codecov.io/gh/mie-lab/trackintel/pull/348/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab#diff-dHJhY2tpbnRlbC9tb2RlbC9zdGF5cG9pbnRzLnB5) | `98.14% <0.00%> (-1.86%)` | :arrow_down: |
| [trackintel/model/triplegs.py](https://codecov.io/gh/mie-lab/trackintel/pull/348/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab#diff-dHJhY2tpbnRlbC9tb2RlbC90cmlwbGVncy5weQ==) | `98.27% <0.00%> (-1.73%)` | :arrow_down: |
| [trackintel/io/file.py](https://codecov.io/gh/mie-lab/trackintel/pull/348/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab#diff-dHJhY2tpbnRlbC9pby9maWxlLnB5) | `95.36% <0.00%> (-0.12%)` | :arrow_down: |
| [trackintel/geogr/distances.py](https://codecov.io/gh/mie-lab/trackintel/pull/348/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab#diff-dHJhY2tpbnRlbC9nZW9nci9kaXN0YW5jZXMucHk=) | `93.20% <0.00%> (ø)` | |
| [trackintel/preprocessing/staypoints.py](https://codecov.io/gh/mie-lab/trackintel/pull/348/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab#diff-dHJhY2tpbnRlbC9wcmVwcm9jZXNzaW5nL3N0YXlwb2ludHMucHk=) | `95.68% <0.00%> (+0.07%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/mie-lab/trackintel/pull/348?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/mie-lab/trackintel/pull/348?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab). Last update [5cd2b9a...b699272](https://codecov.io/gh/mie-lab/trackintel/pull/348?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mie-lab).

henrymartin1: > 
> 
> Is there a way to check which black version the lint-check uses?

only kind of... There is no version defined in the [workflow](https://github.com/mie-lab/trackintel/blob/master/.github/workflows/black.yml) so I guess it uses the latest (or any random version;-) ). You can check the install log when the action fails. It is a bit hidden though...

https://github.com/mie-lab/trackintel/runs/3620136674?check_suite_focus=true
under _Build lgeiger/black-action@v1.0.1_ [here](https://github.com/mie-lab/trackintel/runs/3620136674?check_suite_focus=true#step:2:62) 
```
  Collecting black
    Downloading black-21.9b0-py3-none-any.whl (148 kB)
```





bifbof: > > Is there a way to check which black version the lint-check uses?
> 
> only kind of... There is no version defined in the [workflow](https://github.com/mie-lab/trackintel/blob/master/.github/workflows/black.yml?rgh-link-date=2021-09-16T10%3A38%3A21Z) so I guess it uses the latest (or any random version;-) ). You can check the install log when the action fails. It is a bit hidden though...
> 
> [mie-lab/trackintel/runs/3620136674?check_suite_focus=true](https://github.com/mie-lab/trackintel/runs/3620136674?check_suite_focus=true)
> under _Build lgeiger/black-action@v1.0.1_ [here](https://github.com/mie-lab/trackintel/runs/3620136674?check_suite_focus=true#step:2:62)
> 
> ```
>   Collecting black
>     Downloading black-21.9b0-py3-none-any.whl (148 kB)
> ```

Thanks a lot! That helped.


Patch:
diff --git a/docs/modules/io.rst b/docs/modules/io.rst
index 1483fd6..09083d7 100644
--- a/docs/modules/io.rst
+++ b/docs/modules/io.rst
@@ -45,6 +45,8 @@ GeoDataFrame Import
 
 .. autofunction:: trackintel.io.from_geopandas.read_trips_gpd
 
+.. autofunction:: trackintel.io.from_geopandas.read_tours_gpd
+
 
 PostGIS Import
 ==============
diff --git a/docs/modules/model.rst b/docs/modules/model.rst
index ce54943..139b2a1 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 4e1ce7d..1da4756 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/io/file.py b/trackintel/io/file.py
index 879b322..6443763 100644
--- a/trackintel/io/file.py
+++ b/trackintel/io/file.py
@@ -141,7 +141,7 @@ def write_positionfixes_csv(positionfixes, filename, *args, **kwargs):
     df.to_csv(filename, index=True, *args, **kwargs)
 
 
-def read_triplegs_csv(*args, columns=None, tz=None, index_col=object(), crs=None, **kwargs):
+def read_triplegs_csv(*args, columns=None, tz=None, index_col=object(), geom_col="geom", crs=None, **kwargs):
     """
     Read triplegs from csv file.
 
@@ -163,9 +163,12 @@ def read_triplegs_csv(*args, columns=None, tz=None, index_col=object(), crs=None
         pytz compatible timezone string. If None UTC is assumed.
 
     index_col : str, optional
-        column name to be used as index. If None the default index is assumed
+        Column name to be used as index. If None the default index is assumed
         as unique identifier.
 
+    geom_col : str, default "geom"
+        Name of the column containing the geometry as WKT.
+
     crs : pyproj.crs or str, optional
         Set coordinate reference system. The value can be anything accepted
         by pyproj.CRS.from_user_input(), such as an authority string
@@ -203,7 +206,7 @@ def read_triplegs_csv(*args, columns=None, tz=None, index_col=object(), crs=None
     df = df.rename(columns=columns)
 
     # construct geom column
-    df["geom"] = df["geom"].apply(wkt.loads)
+    df[geom_col] = df[geom_col].apply(wkt.loads)
 
     # transform to datatime
     df["started_at"] = pd.to_datetime(df["started_at"])
@@ -254,7 +257,7 @@ def write_triplegs_csv(triplegs, filename, *args, **kwargs):
     df.to_csv(filename, index=True, *args, **kwargs)
 
 
-def read_staypoints_csv(*args, columns=None, tz=None, index_col=object(), crs=None, **kwargs):
+def read_staypoints_csv(*args, columns=None, tz=None, index_col=object(), geom_col="geom", crs=None, **kwargs):
     """
     Read staypoints from csv file.
 
@@ -280,6 +283,9 @@ def read_staypoints_csv(*args, columns=None, tz=None, index_col=object(), crs=No
         column name to be used as index. If None the default index is assumed
         as unique identifier.
 
+    geom_col : str, default "geom"
+        Name of the column containing the geometry as WKT.
+
     crs : pyproj.crs or str, optional
         Set coordinate reference system. The value can be anything accepted
         by pyproj.CRS.from_user_input(), such as an authority string
@@ -317,7 +323,7 @@ def read_staypoints_csv(*args, columns=None, tz=None, index_col=object(), crs=No
     df = df.rename(columns=columns)
 
     # construct geom column
-    df["geom"] = df["geom"].apply(wkt.loads)
+    df[geom_col] = df[geom_col].apply(wkt.loads)
 
     # transform to datatime
     df["started_at"] = pd.to_datetime(df["started_at"])
@@ -368,7 +374,7 @@ def write_staypoints_csv(staypoints, filename, *args, **kwargs):
     df.to_csv(filename, index=True, *args, **kwargs)
 
 
-def read_locations_csv(*args, columns=None, index_col=object(), crs=None, **kwargs):
+def read_locations_csv(*args, columns=None, index_col=object(), geom_col="geom", crs=None, **kwargs):
     """
     Read locations from csv file.
 
@@ -472,7 +478,7 @@ def write_locations_csv(locations, filename, *args, **kwargs):
     df.to_csv(filename, index=True, *args, **kwargs)
 
 
-def read_trips_csv(*args, columns=None, tz=None, index_col=object(), **kwargs):
+def read_trips_csv(*args, columns=None, tz=None, index_col=object(), geom_col=None, crs=None, **kwargs):
     """
     Read trips from csv file.
 
@@ -498,6 +504,15 @@ def read_trips_csv(*args, columns=None, tz=None, index_col=object(), **kwargs):
         column name to be used as index. If None the default index is assumed
         as unique identifier.
 
+    geom_col : str, default None
+        Name of the column containing the geometry as WKT.
+        If None no geometry gets added.
+
+    crs : pyproj.crs or str, optional
+        Set coordinate reference system. The value can be anything accepted
+        by pyproj.CRS.from_user_input(), such as an authority string
+        (eg “EPSG:4326”) or a WKT string. Ignored if geom_col is None.
+
     kwargs
         Additional keyword arguments passed to pd.read_csv().
 
@@ -508,7 +523,7 @@ def read_trips_csv(*args, columns=None, tz=None, index_col=object(), **kwargs):
 
     Notes
     -----
-    No geometry is required for trackintel trips.
+    Geometry is not mandatory for trackintel trips.
 
     Examples
     --------
@@ -546,9 +561,9 @@ def read_trips_csv(*args, columns=None, tz=None, index_col=object(), **kwargs):
             trips[col] = _localize_timestamp(dt_series=trips[col], pytz_tzinfo=tz, col_name=col)
 
     # convert to geodataframe
-    if "geom" in trips.columns:
-        trips["geom"] = trips["geom"].apply(wkt.loads)
-        trips = gpd.GeoDataFrame(trips, geometry="geom")
+    if geom_col is not None:
+        trips[geom_col] = trips[geom_col].apply(wkt.loads)
+        trips = gpd.GeoDataFrame(trips, geometry=geom_col, crs=crs)
 
     # assert validity of trips
     trips.as_trips
diff --git a/trackintel/io/from_geopandas.py b/trackintel/io/from_geopandas.py
index 2d0bf34..5e101c1 100644
--- a/trackintel/io/from_geopandas.py
+++ b/trackintel/io/from_geopandas.py
@@ -251,14 +251,7 @@ def read_trips_gpd(
     if mapper is not None:
         columns.update(mapper)
 
-    if geom_col is not None:  # handle (Geo)DataFrame modes.
-        trips = _trackintel_model(gdf, columns, geom_col, crs, ["started_at", "finished_at"], tz)
-    else:
-        trips = gdf.rename(columns=columns)
-        # check and/or set timezone
-        for col in ["started_at", "finished_at"]:
-            if not pd.api.types.is_datetime64tz_dtype(trips[col]):
-                trips[col] = _localize_timestamp(dt_series=trips[col], pytz_tzinfo=tz, col_name=col)
+    trips = _trackintel_model(gdf, columns, geom_col, crs, ["started_at", "finished_at"], tz)
 
     # assert validity of trips
     trips.as_trips
@@ -323,10 +316,8 @@ def read_tours_gpd(
     user_id="user_id",
     started_at="started_at",
     finished_at="finished_at",
-    location_id="location_id",
-    journey="journey",
     tz=None,
-    mapper={},
+    mapper=None,
 ):
     """
     Read tours from GeoDataFrames.
@@ -336,48 +327,42 @@ def read_tours_gpd(
     Parameters
     ----------
     gdf : GeoDataFrame
-        GeoDataFrame with valid point geometry, containing the locations to import.
+        GeoDataFrame containing the tours to import.
 
     user_id : str, default 'user_id'
-        name of the column storing the user_id.
+        Name of the column storing the user_id.
 
     started_at : str, default 'started_at'
-        name of the column storing the starttime of the staypoints.
+        Name of the column storing the start time of the tours.
 
     finished_at : str, default 'finished_at'
-        name of the column storing the endtime of the staypoints.
+        Name of the column storing the end time of the tours.
 
-    location_id : str, default 'location_id'
-        the name of the column storing the id of the location where the tour starts and ends.
-
-    journey : str, default 'journey'
-        name of the column storing the information (bool) if the tour is a journey.
+    tz : str, optional
+        pytz compatible timezone string. If None UTC is assumed.
 
     mapper : dict, optional
-        further columns that should be renamed.
+        Further columns that should be renamed.
 
     Returns
     -------
-    trs : GeoDataFrame (as trackintel tours)
+    tours : GeoDataFrame (as trackintel tours)
         A GeoDataFrame containing the tours
     """
-    # columns = {user_id: 'user_id',
-    #            started_at: 'tracked_at',
-    #            finished_at: 'finished_at',
-    #            location_id: 'location_id',
-    #            journey: 'journey'}
-    # columns.update(mapper)
+    columns = {
+        user_id: "user_id",
+        started_at: "started_at",
+        finished_at: "finished_at",
+    }
+    if mapper is not None:
+        columns.update(mapper)
 
-    # trs = gdf.rename(columns=columns)
+    tours = _trackintel_model(gdf, set_names=columns, tz_cols=["started_at", "finished_at"], tz=tz)
 
-    # # check and/or set timezone
-    # for col in ['started_at', 'finished_at']:
-    #     if not pd.api.types.is_datetime64tz_dtype(trs[col]):
-    #         trs[col] = localize_timestamp(dt_series=trs[col], pytz_tzinfo=tz, col_name=col)
+    # assert validity of tours
+    tours.as_tours
 
-    # trs.as_tours
-    # return trs
-    pass
+    return tours
 
 
 def _trackintel_model(gdf, set_names=None, geom_col=None, crs=None, tz_cols=None, tz=None):
@@ -413,6 +398,16 @@ def _trackintel_model(gdf, set_names=None, geom_col=None, crs=None, tz_cols=None
     if set_names is not None:
         gdf = gdf.rename(columns=set_names)
 
+    if tz_cols is not None:
+        for col in tz_cols:
+            if not pd.api.types.is_datetime64tz_dtype(gdf[col]):
+                gdf[col] = _localize_timestamp(dt_series=gdf[col], pytz_tzinfo=tz, col_name=col)
+
+    # If is not GeoDataFrame and no geom_col is set end early.
+    # That allows us to handle DataFrames and GeoDataFrames in one function.
+    if not isinstance(gdf, gpd.GeoDataFrame) and geom_col is None:
+        return gdf
+
     if geom_col is not None:
         gdf = gdf.set_geometry(geom_col)
     else:
@@ -424,9 +419,4 @@ def _trackintel_model(gdf, set_names=None, geom_col=None, crs=None, tz_cols=None
     if crs is not None:
         gdf = gdf.set_crs(crs)
 
-    if tz_cols is not None:
-        for col in tz_cols:
-            if not pd.api.types.is_datetime64tz_dtype(gdf[col]):
-                gdf[col] = _localize_timestamp(dt_series=gdf[col], pytz_tzinfo=tz, col_name=col)
-
     return gdf
diff --git a/trackintel/model/__init__.py b/trackintel/model/__init__.py
index f94f55f..f24d9dd 100644
--- a/trackintel/model/__init__.py
+++ b/trackintel/model/__init__.py
@@ -3,5 +3,4 @@ from .staypoints import StaypointsAccessor
 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 01f391c..0000000
--- 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
diff --git a/trackintel/preprocessing/trips.py b/trackintel/preprocessing/trips.py
index 53aa921..bb74cf0 100644
--- a/trackintel/preprocessing/trips.py
+++ b/trackintel/preprocessing/trips.py
@@ -19,12 +19,15 @@ def get_trips_grouped(trips, tours):
     tours: GeoDataFrame (as trackintel tours)
         Output of generate_tours function, must contain column "trips" with list of trip ids on tour
 
-
     Returns
     -------
     trips_grouped_by_tour: DataFrameGroupBy object
         Trips grouped by tour id
 
+    Examples
+    --------
+    >>> get_trips_grouped(trips, tours)
+
     Notes
     -------
     This function is necessary because when running generate_tours, one trip only gets the tour ID of the smallest
@@ -91,6 +94,10 @@ def generate_tours(
     tours: GeoDataFrame (as trackintel tours)
         The generated tours
 
+    Examples
+    --------
+    >>> trips.as_trips.generate_tours(staypoints)
+
     Notes
     -------
     - Tours are defined as a collection of trips in a certain time frame that start and end at the same point
diff --git a/trackintel/preprocessing/util.py b/trackintel/preprocessing/util.py
index 04c6874..5f28ee8 100644
--- a/trackintel/preprocessing/util.py
+++ b/trackintel/preprocessing/util.py
@@ -5,7 +5,7 @@ from tqdm import tqdm
 
 def calc_temp_overlap(start_1, end_1, start_2, end_2):
     """
-    Calculate the portion of the first time span that overlaps with the second
+    Calculate the portion of the first time span that overlaps with the second.
 
     Parameters
     ----------
@@ -21,7 +21,11 @@ def calc_temp_overlap(start_1, end_1, start_2, end_2):
     Returns
     -------
     float:
-        The ratio by which the
+        The ratio by which the first timespan overlaps with the second.
+
+    Examples
+    --------
+    >>> ti.preprocessing.calc_temp_overlap(start_1, end_1, start_2, end_2)
 
     """
 
@@ -94,6 +98,11 @@ def applyParallel(dfGrouped, func, n_jobs, print_progress, **kwargs):
     -------
     pd.DataFrame:
         The result of dfGrouped.apply(func)
+
+    Examples
+    --------
+    >>> from trackintel.preprocessing.util import applyParallel
+    >>> applyParallel(tpfs.groupby("user_id", as_index=False), func, n_jobs=2)
     """
     df_ls = Parallel(n_jobs=n_jobs)(
         delayed(func)(group, **kwargs) for _, group in tqdm(dfGrouped, disable=not print_progress)
diff --git a/trackintel/visualization/osm.py b/trackintel/visualization/osm.py
index 992402f..9863fb3 100644
--- a/trackintel/visualization/osm.py
+++ b/trackintel/visualization/osm.py
@@ -1,12 +1,12 @@
 import logging
 
 import osmnx as ox
-from networkx.exception import NetworkXPointlessConcept
 from matplotlib.collections import LineCollection
+from networkx.exception import NetworkXPointlessConcept
 
 
 def plot_osm_streets(north, south, east, west, ax):
-    """Plots OpenStreetMap streets onto an axis.
+    """Plots with osmnx OpenStreetMap streets onto an axis.
 
     Parameters
     ----------
@@ -21,6 +21,13 @@ def plot_osm_streets(north, south, east, west, ax):
 
     west : float
         The westernmost coordinate.
+
+    ax : matplotlib.pyplot.Artist, optional
+        Axis on which to draw the plot.
+
+    Examples
+    --------
+    >>> ti.visualization.osm.plot_osm_street(47.392, 47.364, 8.557, 8.509, ax)
     """
     try:
         G = ox.graph_from_bbox(north, south, east, west, network_type="drive")
diff --git a/trackintel/visualization/util.py b/trackintel/visualization/util.py
index 2e77f94..063440a 100644
--- a/trackintel/visualization/util.py
+++ b/trackintel/visualization/util.py
@@ -1,15 +1,10 @@
-import time
 import logging
-import warnings
+import time
 
 import matplotlib
 import matplotlib.pyplot as plt
 import numpy as np
-
-from functools import partial
 from pint import UnitRegistry
-from shapely.geometry import Point
-
 
 ureg = UnitRegistry()
 
@@ -32,6 +27,10 @@ def a4_figsize(fig_height_mm=None, columns=2):
     -------
     (float, float)
         The width and height in which to plot a figure to fit on an A4 sheet.
+
+    Examples
+    --------
+    >>> ti.visualization.util.a4_figsize(columns=4)
     """
     if columns == 1:
         fig_width_mm = 84.0
@@ -100,6 +99,10 @@ def save_fig(out_filename, tight="tight", formats=["png", "pdf"]):
         How the bounding box should be drawn.
     formats : list
         A list denoting in which formats this figure should be saved ('png' or 'pdf').
+
+    Examples
+    --------
+    >>> ti.visualization.util("figure", formats=["png"])
     """
 
     if out_filename.endswith(".png"):


Test patch:
diff --git a/tests/data/tours.csv b/tests/data/tours.csv
new file mode 100644
index 0000000..7613a17
--- /dev/null
+++ b/tests/data/tours.csv
@@ -0,0 +1,3 @@
+id;user_id;started_at;finished_at;
+0;1;2015-11-27T08:00:00Z;2015-11-27T10:00:00Z;
+1;1;2015-11-27T12:00:00Z;2015-11-27T14:00:00Z;
diff --git a/tests/io/test_from_geopandas.py b/tests/io/test_from_geopandas.py
index cabf841..c04a724 100644
--- a/tests/io/test_from_geopandas.py
+++ b/tests/io/test_from_geopandas.py
@@ -259,7 +259,7 @@ def example_trips():
 class TestRead_Trips_Gpd:
     """Test `read_trips_gpd()` function."""
 
-    def test_cvs(self):
+    def test_csv(self):
         """Test if the results of reading from gpd and csv agrees."""
         df = pd.read_csv(os.path.join("tests", "data", "trips.csv"), sep=";")
         df.set_index("id", inplace=True)
@@ -297,9 +297,40 @@ class TestRead_Trips_Gpd:
         assert_geodataframe_equal(trips, example_trips)
 
 
+@pytest.fixture
+def example_tours():
+    """Model conform tours to test with."""
+    start = pd.Timestamp("1971-01-01 00:00:00", tz="utc")
+    h = pd.Timedelta("1h")
+
+    list_dict = [
+        {"user_id": 0, "started_at": start + 0 * h, "finished_at": start + 1 * h},
+        {"user_id": 0, "started_at": start + 2 * h, "finished_at": start + 3 * h},
+        {"user_id": 1, "started_at": start + 4 * h, "finished_at": start + 5 * h},
+    ]
+    tours = pd.DataFrame(data=list_dict)
+    tours.index.name = "id"
+    tours.as_tours
+    return tours
+
+
 class TestRead_Tours_Gpd:
     """Test `read_trips_gpd()` function."""
 
-    def test_read_tours_gpd(self):
-        # TODO: implement tests for reading tours from Geopandas
-        pass
+    def test_csv(self):
+        """Test if the results of reading from gpd and csv agrees."""
+        tours_file = os.path.join("tests", "data", "tours.csv")
+        df = pd.read_csv(tours_file, sep=";")
+        df.set_index("id", inplace=True)
+        tours_from_gpd = read_tours_gpd(df, tz="utc")
+
+        tours_from_csv = ti.read_tours_csv(tours_file, sep=";", tz="utc", index_col="id")
+
+        assert_frame_equal(tours_from_gpd, tours_from_csv, check_exact=False)
+
+    def test_mapper(self, example_tours):
+        example_tours["additional_col"] = [11, 22, 33]
+        mapper = {"additional_col": "additional_col_renamed"}
+        tours = read_tours_gpd(example_tours, mapper=mapper)
+        example_tours.rename(columns=mapper, inplace=True)
+        assert_frame_equal(tours, example_tours)
diff --git a/tests/model/test_trips.py b/tests/model/test_trips.py
index f2b87ab..a418894 100644
--- a/tests/model/test_trips.py
+++ b/tests/model/test_trips.py
@@ -8,7 +8,8 @@ import trackintel as ti
 @pytest.fixture
 def testdata_trips():
     """Read trips test data from file."""
-    test_trips = ti.read_trips_csv(os.path.join("tests", "data", "geolife_long", "trips.csv"), index_col="id")
+    path = os.path.join("tests", "data", "geolife_long", "trips.csv")
+    test_trips = ti.read_trips_csv(path, index_col="id", geom_col="geom")
     return test_trips
 
 
diff --git a/tests/model/test_users.py b/tests/model/test_users.py
deleted file mode 100644
index efec648..0000000
--- 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
diff --git a/tests/preprocessing/test_triplegs.py b/tests/preprocessing/test_triplegs.py
index 11f8e8e..fc7ad42 100644
--- a/tests/preprocessing/test_triplegs.py
+++ b/tests/preprocessing/test_triplegs.py
@@ -78,7 +78,8 @@ class TestGenerate_trips:
     def test_generate_trips(self, example_triplegs_higher_gap_threshold):
         """Test if we can generate the example trips based on example data."""
         # load pregenerated trips
-        trips_loaded = ti.read_trips_csv(os.path.join("tests", "data", "geolife_long", "trips.csv"), index_col="id")
+        path = os.path.join("tests", "data", "geolife_long", "trips.csv")
+        trips_loaded = ti.read_trips_csv(path, index_col="id", geom_col="geom", crs=None)
 
         # create trips from geolife (based on positionfixes) - with gap_threshold 1e6
         sp, tpls = example_triplegs_higher_gap_threshold
diff --git a/tests/preprocessing/test_trips.py b/tests/preprocessing/test_trips.py
index bf3c86d..0aa69f4 100644
--- a/tests/preprocessing/test_trips.py
+++ b/tests/preprocessing/test_trips.py
@@ -234,12 +234,12 @@ class TestGenerate_tours:
 
     def test_generate_tours_geolife(self):
         """Test tour generation also on the geolife dataset"""
-        trips = ti.io.file.read_trips_csv(os.path.join("tests", "data", "geolife_long", "trips.csv"), index_col="id")
+        path_trips = os.path.join("tests", "data", "geolife_long", "trips.csv")
+        trips = ti.io.file.read_trips_csv(path_trips, index_col="id", geom_col="geom", crs="EPSG:4326")
         _, tours = ti.preprocessing.trips.generate_tours(trips, max_dist=100)
 
-        tours_loaded = ti.io.file.read_tours_csv(
-            os.path.join("tests", "data", "geolife_long", "tours.csv"), index_col="id"
-        )
+        path_tours = os.path.join("tests", "data", "geolife_long", "tours.csv")
+        tours_loaded = ti.io.file.read_tours_csv(path_tours, index_col="id")
         # check only first five columns because location ID is empty in this case
         pd.testing.assert_frame_equal(tours_loaded.iloc[:, :5], tours.iloc[:, :5])