def test_pivot_longer_dot_value_and_names_sep(self): """ Test pivot_longer when it receives the .value and names_sep """ DF = gr.Intention() wide = gr.df_make(x=range(0, 6)) wide = gr.tran_mutate( wide, y_Trend=DF.x**2, y_Variability=random.normal(size=6), y_Mixed=DF.x**2 + random.normal(size=6), ) long = gr.tran_pivot_longer( wide, columns=["y_Trend", "y_Variability", "y_Mixed"], names_to=(".value", "type"), names_sep="_" ) check = ["x", "type", "y"] col_check = [x for x in long.columns.values if x in check] result = False if set(col_check) == set(check): result = True self.assertTrue(result)
import numpy as np import pandas as pd from scipy.stats import norm import unittest from context import grama as gr from context import fit from context import models from context import data X = gr.Intention() ## Core function tests ################################################## class TestFits(unittest.TestCase): """Test implementations of fitting procedures """ def setUp(self): ## Smooth model self.md_smooth = (gr.Model() >> gr.cp_function( fun=lambda x: [x, x + 1], var=["x"], out=["y", "z"]) >> gr.cp_marginals(x={ "dist": "uniform", "loc": 0, "scale": 2 }) >> gr.cp_copula_independence()) self.df_smooth = self.md_smooth >> gr.ev_df( df=pd.DataFrame(dict(x=[0, 1, 2])))