Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
partials.test.ts244 linesDownload Raw Back to tests
1// @ts-ignore TS61332import { expect, test } from "vitest";3 4import * as z from "zod/v3";5import { ZodNullable, ZodOptional } from "zod/v3";6import { util } from "../helpers/util.js";7 8const nested = z.object({9  name: z.string(),10  age: z.number(),11  outer: z.object({12    inner: z.string(),13  }),14  array: z.array(z.object({ asdf: z.string() })),15});16 17test("shallow inference", () => {18  const shallow = nested.partial();19  type shallow = z.infer<typeof shallow>;20  type correct = {21    name?: string | undefined;22    age?: number | undefined;23    outer?: { inner: string } | undefined;24    array?: { asdf: string }[] | undefined;25  };26  util.assertEqual<shallow, correct>(true);27});28 29test("shallow partial parse", () => {30  const shallow = nested.partial();31  shallow.parse({});32  shallow.parse({33    name: "asdf",34    age: 23143,35  });36});37 38test("deep partial inference", () => {39  const deep = nested.deepPartial();40  const asdf = deep.shape.array.unwrap().element.shape.asdf.unwrap();41  asdf.parse("asdf");42  type deep = z.infer<typeof deep>;43  type correct = {44    array?: { asdf?: string | undefined }[] | undefined;45    name?: string | undefined;46    age?: number | undefined;47    outer?: { inner?: string | undefined } | undefined;48  };49 50  util.assertEqual<deep, correct>(true);51});52 53test("deep partial parse", () => {54  const deep = nested.deepPartial();55 56  expect(deep.shape.name instanceof z.ZodOptional).toBe(true);57  expect(deep.shape.outer instanceof z.ZodOptional).toBe(true);58  expect(deep.shape.outer._def.innerType instanceof z.ZodObject).toBe(true);59  expect(deep.shape.outer._def.innerType.shape.inner instanceof z.ZodOptional).toBe(true);60  expect(deep.shape.outer._def.innerType.shape.inner._def.innerType instanceof z.ZodString).toBe(true);61});62 63test("deep partial runtime tests", () => {64  const deep = nested.deepPartial();65  deep.parse({});66  deep.parse({67    outer: {},68  });69  deep.parse({70    name: "asdf",71    age: 23143,72    outer: {73      inner: "adsf",74    },75  });76});77 78test("deep partial optional/nullable", () => {79  const schema = z80    .object({81      name: z.string().optional(),82      age: z.number().nullable(),83    })84    .deepPartial();85 86  expect(schema.shape.name.unwrap()).toBeInstanceOf(ZodOptional);87  expect(schema.shape.age.unwrap()).toBeInstanceOf(ZodNullable);88});89 90test("deep partial tuple", () => {91  const schema = z92    .object({93      tuple: z.tuple([94        z.object({95          name: z.string().optional(),96          age: z.number().nullable(),97        }),98      ]),99    })100    .deepPartial();101 102  expect(schema.shape.tuple.unwrap().items[0].shape.name).toBeInstanceOf(ZodOptional);103});104 105test("deep partial inference", () => {106  const mySchema = z.object({107    name: z.string(),108    array: z.array(z.object({ asdf: z.string() })),109    tuple: z.tuple([z.object({ value: z.string() })]),110  });111 112  const partialed = mySchema.deepPartial();113  type partialed = z.infer<typeof partialed>;114  type expected = {115    name?: string | undefined;116    array?:117      | {118          asdf?: string | undefined;119        }[]120      | undefined;121    tuple?: [{ value?: string | undefined }] | undefined;122  };123  util.assertEqual<expected, partialed>(true);124});125 126test("required", () => {127  const object = z.object({128    name: z.string(),129    age: z.number().optional(),130    field: z.string().optional().default("asdf"),131    nullableField: z.number().nullable(),132    nullishField: z.string().nullish(),133  });134 135  const requiredObject = object.required();136  expect(requiredObject.shape.name).toBeInstanceOf(z.ZodString);137  expect(requiredObject.shape.age).toBeInstanceOf(z.ZodNumber);138  expect(requiredObject.shape.field).toBeInstanceOf(z.ZodDefault);139  expect(requiredObject.shape.nullableField).toBeInstanceOf(z.ZodNullable);140  expect(requiredObject.shape.nullishField).toBeInstanceOf(z.ZodNullable);141});142 143test("required inference", () => {144  const object = z.object({145    name: z.string(),146    age: z.number().optional(),147    field: z.string().optional().default("asdf"),148    nullableField: z.number().nullable(),149    nullishField: z.string().nullish(),150  });151 152  const requiredObject = object.required();153 154  type required = z.infer<typeof requiredObject>;155  type expected = {156    name: string;157    age: number;158    field: string;159    nullableField: number | null;160    nullishField: string | null;161  };162  util.assertEqual<expected, required>(true);163});164 165test("required with mask", () => {166  const object = z.object({167    name: z.string(),168    age: z.number().optional(),169    field: z.string().optional().default("asdf"),170    country: z.string().optional(),171  });172 173  const requiredObject = object.required({ age: true });174  expect(requiredObject.shape.name).toBeInstanceOf(z.ZodString);175  expect(requiredObject.shape.age).toBeInstanceOf(z.ZodNumber);176  expect(requiredObject.shape.field).toBeInstanceOf(z.ZodDefault);177  expect(requiredObject.shape.country).toBeInstanceOf(z.ZodOptional);178});179 180test("required with mask -- ignore falsy values", () => {181  const object = z.object({182    name: z.string(),183    age: z.number().optional(),184    field: z.string().optional().default("asdf"),185    country: z.string().optional(),186  });187 188  // @ts-expect-error189  const requiredObject = object.required({ age: true, country: false });190  expect(requiredObject.shape.name).toBeInstanceOf(z.ZodString);191  expect(requiredObject.shape.age).toBeInstanceOf(z.ZodNumber);192  expect(requiredObject.shape.field).toBeInstanceOf(z.ZodDefault);193  expect(requiredObject.shape.country).toBeInstanceOf(z.ZodOptional);194});195 196test("partial with mask", async () => {197  const object = z.object({198    name: z.string(),199    age: z.number().optional(),200    field: z.string().optional().default("asdf"),201    country: z.string(),202  });203 204  const masked = object.partial({ age: true, field: true, name: true }).strict();205 206  expect(masked.shape.name).toBeInstanceOf(z.ZodOptional);207  expect(masked.shape.age).toBeInstanceOf(z.ZodOptional);208  expect(masked.shape.field).toBeInstanceOf(z.ZodOptional);209  expect(masked.shape.country).toBeInstanceOf(z.ZodString);210 211  masked.parse({ country: "US" });212  await masked.parseAsync({ country: "US" });213});214 215test("partial with mask -- ignore falsy values", async () => {216  const object = z.object({217    name: z.string(),218    age: z.number().optional(),219    field: z.string().optional().default("asdf"),220    country: z.string(),221  });222 223  // @ts-expect-error224  const masked = object.partial({ name: true, country: false }).strict();225 226  expect(masked.shape.name).toBeInstanceOf(z.ZodOptional);227  expect(masked.shape.age).toBeInstanceOf(z.ZodOptional);228  expect(masked.shape.field).toBeInstanceOf(z.ZodDefault);229  expect(masked.shape.country).toBeInstanceOf(z.ZodString);230 231  masked.parse({ country: "US" });232  await masked.parseAsync({ country: "US" });233});234 235test("deeppartial array", () => {236  const schema = z.object({ array: z.string().array().min(42) }).deepPartial();237 238  // works as expected239  schema.parse({});240 241  // should be false, but is true242  expect(schema.safeParse({ array: [] }).success).toBe(false);243});244 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai