# Path: econtools/util/gentools.py
# def force_list(x: Any) -> list:
#     """If type not `list`, pass to `force_interable`, then convert to list."""
#     if isinstance(x, list):
#         return x
#     else:
#         return list(force_iterable(x))
# 
# def force_df(s: Union[pd.DataFrame, pd.Series],
#              name: Optional[str]=None) -> pd.DataFrame:
#     """
#     Forces a Series to a DataFrame. DataFrames are returned unaffected. Other
#     objects raise `ValueError`.
#     """
#     # Check if DF or Series
#     if isinstance(s, pd.core.frame.DataFrame):
#         return s
#     elif not isinstance(s, pd.core.series.Series):
#         raise ValueError("`s` is a {}".format(type(s)))
#     else:
#         return s.to_frame(name)


from typing import Optional, List
from econtools.util.gentools import force_list, force_df
import pandas as pd
import numpy as np
import numpy.linalg as la




def add_cons(df):
    df = df.copy()  # Protect original df

    if df.ndim == 1:
        df = pd.DataFrame(df)

    df['_cons'] = np.ones(df.shape[0])
    return df


def flag_sample(df, *args):
    varlist = []
    for var in args:
        if var is not None:

# Path: econtools/util/gentools.py
# def force_list(x: Any) -> list:
#     """If type not `list`, pass to `force_interable`, then convert to list."""
#     if isinstance(x, list):
#         return x
#     else:
#         return list(force_iterable(x))
# 
# def force_df(s: Union[pd.DataFrame, pd.Series],
#              name: Optional[str]=None) -> pd.DataFrame:
#     """
#     Forces a Series to a DataFrame. DataFrames are returned unaffected. Other
#     objects raise `ValueError`.
#     """
#     # Check if DF or Series
#     if isinstance(s, pd.core.frame.DataFrame):
#         return s
#     elif not isinstance(s, pd.core.series.Series):
#         raise ValueError("`s` is a {}".format(type(s)))
#     else:
#         return s.to_frame(name)


# Path: econtools/metrics/regutil.py
from typing import Optional, List
from econtools.util.gentools import force_list, force_df
import pandas as pd
import numpy as np
import numpy.linalg as la





def add_cons(df):
    df = df.copy()  # Protect original df

    if df.ndim == 1:
        df = pd.DataFrame(df)

    df['_cons'] = np.ones(df.shape[0])
    return df


def flag_sample(df, *args):
    varlist = []
    for var in args:
        if var is not None:

            varlist += force_list(var)