<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 30 09:10:56 2018

@author: barnhark
"""
import os

import shapefile as ps

from landlab.grid.network import NetworkModelGrid


def read_shapefile(file):
    """Read shapefile and create a NetworkModelGrid.

    Text here about assumptions


    Parameters
    ----------
    file : str
        File path to a valid shapefile

    Examples
    --------
    >>> # an example will be here.
    """

    if os.path.exists(file) is False:
        raise ValueError(
            ("landlab.io.shapefile was passed a filepath that does " "not exist.")
        )

    sf = ps.Reader(file)

    if sf.shapeType != 3:
        raise ValueError(
            (
                "landlab.io.shapefile read requires a polyline "
                "type shapefile. The provided shapefile does "
                "not meet these requirements."
            )
        )

    # get record information, the firste element is # ('DeletionFlag', 'C', 1, 0)
    # which we will ignore.
    records = sf.fields[1:]

    # initialize data structures for node (x,y) tuples,
    # link (head_node_id, tail_node_id) tuples, and a dictionary of at-link fields.<commit_msg>docs wip<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Functions to read shapefiles and create a NetworkModelGrid
"""
import os

import shapefile as ps

from landlab.grid.network import NetworkModelGrid


def read_shapefile(file):
    """Read shapefile and create a NetworkModelGrid.




    Parameters
    ----------
    file : str
        File path to a valid shapefile
    store_polyline_vertices: bool, optional
        If True (default), store the vertices of the polylines in
        the at_link fields ``x_of_polyline`` and ``y_of_polyline``.

    Examples
    --------
    >>>
    """

    if os.path.exists(file) is False:
        raise ValueError(
            ("landlab.io.shapefile was passed a filepath that does " "not exist.")
        )

    sf = ps.Reader(file)

    if sf.shapeType != 3:
        raise ValueError(
            (
                "landlab.io.shapefile read requires a polyline "
                "type shapefile. The provided shapefile does "
                "not meet these requirements."
            )
        )

    # get record information, the firste element is # ('DeletionFlag', 'C', 1, 0)
    # which we will ignore.
    records = sf.fields[1:]

    # initialize data structures for node (x,y) tuples,
    # link (head_node_id, tail_node_id) tuples, and a dictionary of at-link fields.
{'fraction_non_alphanumeric': 0.10620851229988286, 'fraction_numerical': 0.009371339320577899, 'mean_word_length': 2.124390243902439, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6598285', 'n_tokens_mistral': 806, 'n_tokens_neox': 725, 'n_words': 251}