This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@dataclass | |
class VideoSource(DataSource): | |
filepath: Path | |
image_mode: ImageMode | |
image_height: int | |
image_width: int | |
@property | |
def name(self) -> str: | |
return "VideoSource" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from abc import ABC, abstractmethod | |
from collections.abc import Iterable, Iterator | |
from dataclasses import dataclass | |
from typing import TYPE_CHECKING, Callable, Generic, TypeVar | |
__all__ = [ | |
"Dataset", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct MyCast; | |
#[derive(FunctionArgs)] | |
struct MyCastArgs { | |
input: ExprRef, | |
target: DataType, | |
} | |
impl ScalarFunctionFactory for MyCast { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import daft | |
from daft import DataType as dt | |
from daft import col | |
# here's our raw sample data which is just some json dump from a sensor | |
df = daft.from_pydict( | |
{ | |
"sample": [ | |
'{ "x": 1 }', # missing y, we'll insert 0 in its place | |
'{ "x": 1, "y": 1 }', # ok |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import daft | |
from daft import DataType, Expression, Series, col, udf | |
def from_json(col: Expression, schema: DataType) -> Expression: | |
"""Produces a UDF based upon the input schema.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import modal | |
import os | |
app = modal.App() | |
vol = modal.Volume.from_name("...") | |
@app.local_entrypoint() | |
def put_file(filepath: str): | |
src_path = os.path.abspath(filepath) | |
dst_path = f"/tmp/{os.path.basename(filepath)}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::BTreeSet; | |
use egg::{rewrite as rw, *}; | |
fn main() { | |
let mut egraph: EGraph<SymbolLang, ()> = Default::default(); | |
let a = egraph.add(SymbolLang::leaf("a")); | |
let b = egraph.add(SymbolLang::leaf("b")); | |
let _ = egraph.add(SymbolLang::new("foo", vec![a, b])); | |
egraph.rebuild(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MY_NUM: usize = crabtime::eval! { | |
(std::f32::consts::PI.sqrt() * 10.0).round() as usize | |
}; | |
// you can use #[macro_export] | |
#[crabtime::function] | |
fn gen_positions_struct() -> &str { | |
" | |
#[derive(Debug)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This gist shows how you can patch tabulate to print daft dataframes with options. | |
""" | |
import tabulate | |
from tabulate import DataRow, Line, TableFormat | |
# add a default which is like our rust comfytable | |
tabulate._table_formats["default"] = TableFormat( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.partiql.plan.builder | |
import org.partiql.plan.Collation | |
import org.partiql.plan.Exclusion | |
import org.partiql.plan.JoinType | |
import org.partiql.plan.rel.Rel | |
import org.partiql.plan.rel.RelAggregate | |
/** | |
* DataFrame style fluent-builder for PartiQL logical plans. |
NewerOlder