<commit_before># visualise_doosabin_regression.py

# Imports
import argparse
import numpy as np

# Requires `subdivision`.
from subdivision import doosabin

# Requires `rscommon`.
from rscommon.face_array import raw_face_array_to_sequence
from rscommon import vtk_

# main
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('input_path')
    parser.add_argument('--sample-density', type=int, default=16)
    args = parser.parse_args()

    s = Problem()
    with open(args.input_path, 'rb') as fp:
        s.ParseFromString(fp.read())

    Y = pb.load_array(s, 'y', 3)
    T = raw_face_array_to_sequence(pb.load_array(s, 't'))
    X = pb.load_array(s, 'x', 3)
    p = pb.load_array(s, 'p')
    U = pb.load_array(s, 'u', 2)

    surface = doosabin.surface(T)
    pd, Ud, Td = surface.uniform_parameterisation(args.sample_density)
    M = surface.M(pd, Ud, X)

    a = {}
    a['Y'] = vtk_.points(Y, ('SetRadius', 0.025),
                            ('SetThetaResolution', 16),
                            ('SetPhiResolution', 16))
    camera = vtk_.vtk.vtkCamera()
    a['M'] = vtk_.surface(Td, M, camera=camera)
    a['M'].GetProperty().SetColor(0.216, 0.494, 0.722)
    a['M'].GetProperty().SetSpecular(1.0)
    a['M'].GetProperty().SetOpacity(0.6)

    MU = surface.M(p, U, X)
    a['MU'] = vtk_.points(MU, ('SetRadius', 0.015),
                              ('SetThetaResolution', 16),
                              ('SetPhiResolution', 16))

    i = np.arange(p.size)
    a['U'] = vtk_.tubes(np.c_[i, i + p.size], np.r_['0,2', MU, Y],
                        ('SetRadius', 0.01),
                        ('SetNumberOfSides', 16))<commit_msg>Use `json` in python/visualise_doosabin_regression.py<commit_after># visualise_doosabin_regression.py

# Imports
import argparse
import numpy as np
import json

# Requires `subdivision`.
from subdivision import doosabin

# Requires `rscommon`.
from rscommon.face_array import raw_face_array_to_sequence
from rscommon import vtk_

# main
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('input_path')
    parser.add_argument('--sample-density', type=int, default=16)
    args = parser.parse_args()

    with open(args.input_path, 'rb') as fp:
        z = json.loads(fp.read())
    def z_getitem(k, cols=None):
        a = np.array(z[k])
        return a.reshape(-1, cols) if cols is not None else a

    Y = z_getitem('Y', 3)
    T = raw_face_array_to_sequence(z_getitem('raw_face_array'))
    X = z_getitem('X', 3)
    p = z_getitem('p')
    U = z_getitem('U', 2)

    surface = doosabin.surface(T)
    pd, Ud, Td = surface.uniform_parameterisation(args.sample_density)
    M = surface.M(pd, Ud, X)

    a = {}
    a['Y'] = vtk_.points(Y, ('SetRadius', 0.025),
                            ('SetThetaResolution', 16),
                            ('SetPhiResolution', 16))
    camera = vtk_.vtk.vtkCamera()
    a['M'] = vtk_.surface(Td, M, camera=camera)
    a['M'].GetProperty().SetColor(0.216, 0.494, 0.722)
    a['M'].GetProperty().SetSpecular(1.0)
    a['M'].GetProperty().SetOpacity(0.6)

    MU = surface.M(p, U, X)
    a['MU'] = vtk_.points(MU, ('SetRadius', 0.015),
                              ('SetThetaResolution', 16),
                              ('SetPhiResolution', 16))

    i = np.arange(p.size)
    a['U'] = vtk_.tubes(np.c_[i, i + p.size], np.r_['0,2', MU, Y],
                        ('SetRadius', 0.01),
                        ('SetNumberOfSides', 16))
{'fraction_non_alphanumeric': 0.16027673681176133, 'fraction_numerical': 0.025655808590371865, 'mean_word_length': 2.555327868852459, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6632462', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1238, 'n_words': 247}