text string | label_name string | labels int64 |
|---|---|---|
from pydantic import BaseModel, Field
last_id: int = 0
class CodeNote(BaseModel):
id: int = Field(title="note id", default_factory=lambda: CodeNote.generate_id())
name: str = Field(title="note name")
code_block: str = Field(title="note code block")
@staticmethod
def generate_id() -> int:
... | Python | 1 |
#!/usr/bin/env python3
""" Duck typing - first element of a sequence """
from typing import Any, Union, Sequence, Iterable, List, Tuple
# The types of the elements of the input are not know
def safe_first_element(lst: Sequence[Any]) -> Union[Any, None]:
""" Safe first element """
if lst:
return lst[0]... | Python | 1 |
ts_grade) is list:
bboxes = results_grade
else:
bboxes = results_grade.boxes.data.cpu().numpy()
for box in bboxes:
xmin = int(box[0])
ymin = int(box[1])
xmax = int(box[2])
ymax = int(box[3])
if len(box) >= 6:
... | Python | 1 |
#[panic_handler]
pub fn panic(_info: &::core::panic::PanicInfo) -> ! {
revert(ApiError::OutOfMemory)
}
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}
#[no_mangle]
pub extern "C" fn call() {
let initial_memory_pages = memory_size();
// Grow memory into exactly MAX_MEMORY_PAGES - GROW_MARGIN
... | Rust | 0 |
timeauth_verify(&out1, &m, &k);
let r2 = tweetnacl::onetimeauth_verify(&out2, &m, &k);
assert_eq!(r1, r2);
})
}
#[test]
fn stream() {
let mut rng = rand::thread_rng();
prob_test(10, || {
let len = rng.gen_range(0..1024);
println!("length: {}", len);
let mut m = vec... | Rust | 0 |
import os, sys
sys.path.insert(1, "/".join(os.path.realpath(__file__).split("/")[0:-2]))
from fsm.machine import *
from fsm.assign import *
from fsm.optimize import calcBest
s0, s1, s2, s3, s4 = createStatesByCount(5)
m = MooreMachine(symbols("X"), symbols("Z"))
m.addState(s0, (s0, s1), 1)
m.addState(s1, (s2, s4), 0... | Python | 1 |
Margin=72,
leftMargin=72,
topMargin=72,
bottomMargin=72
)
# Define styles
styles = getSampleStyleSheet()
title_style = styles['Title']
heading_style = styles['Heading2']
normal_style = styles['Normal']
# Create a custom style for Braille text
braille_sty... | Python | 1 |
nk,))
if not items_for_main_db:
logging.warning("정제 후 삽입할 유효한 데이터가 없습니다.")
return
try:
# (DB 저장 로직은 기존과 동일)
conn_main = sqlite3.connect(DB_PATH)
cursor_main = conn_main.cursor()
cursor_main.executemany("""
INSERT OR IGNORE INTO knowledge_base (link, ... | Python | 1 |
);
Ok(())
}
// Computed Replicas
1 => {
let mut param = TopicReplicaParam::default();
param.decode(src, version)?;
*self = TopicSpec::Computed(param);
Ok(())
}
// Unexpected type... | Rust | 0 |
print(f'{self.split} unanswerable question {len(json_data) - len(lang_data)},'
+ f'answerable question {len(lang_data)}')
return lang_data, scan_ids, scan_to_item_idxs
def build_answer(self):
train_data = json.load(open(os.path.join(self.base_dir,
'anno... | Python | 1 |
ngers centered
self.world.add_constraint(
self.body,
self.body.links["panda_leftfinger"],
self.body,
self.body.links["panda_rightfinger"],
pybullet.JOINT_GEAR,
[1.0, 0.0, 0.0],
Transform.identity(),
Transform.identit... | Python | 1 |
ror!("[queue:{}] failed to create new job: {}", &queue_name, err);
Ok(HttpResponse::ServiceUnavailable().body(err.to_string()))
},
Err(err) => {
error!("[queue:{}] failed to create new job: {}", &queue_name, err);
... | Rust | 0 |
WhiteBeam service");
}
Ok(())
}
fn run_stop() -> Result<(), Box<dyn Error>> {
if !platform::is_superuser() { return Err("WhiteBeam: Insufficient privileges to stop WhiteBeam service".into()); }
if !valid_auth()? { return Err("WhiteBeam: Authorization failed".into()); }
println!("WhiteBeam: Stoppin... | Rust | 0 |
{
type Output = Vector<T>;
/// Subtract a scalar from vector elements
///
/// # Example
///
/// ```
/// use mathru::algebra::linear::Vector;
///
/// let a: Vector<f64> = Vector::new_column(vec![1.0, 2.0, 3.0, 4.0]);
/// let res_ref: Vector<f64> = Vector::new_column(vec![-4.0, -3... | Rust | 0 |
#
# COPYRIGHT:
# The Leginon software is Copyright under
# Apache License, Version 2.0
# For terms of the license agreement
# see http://leginon.org
#
import os
import ConfigParser
import pyami.fileutil
leginonconfigparser = ConfigParser.SafeConfigParser()
confdirs = pyami.fileutil.get_config_dirs(packag... | Python | 1 |
"""
This is just a utility that I use to extract the projector for quantized models.
It is NOT necessary at all to train, or run inference/serve demos.
Use this script ONLY if you fully understand its implications.
"""
import os
import argparse
import torch
import json
from collections import defaultdict
def parse_... | Python | 1 |
n loss_types:
value = rec['value-' + loss_type]
for peril in binary_perils:
rec['loss-%s-%s' % (loss_type, peril)] = haz[
'Volcanic_' + peril] * value
for occupant in occupants:
occ = rec[occupant]
for peril in binary_perils:
... | Python | 1 |
hereum.is_erc20_deposit_approved(token.address).await?);
}
// To be sure that the deposit is committed, we need to listen to the event `NewPriorityRequest`
// rust SDK doesn't support getting this information yet, but it will be added soon.
// assert_eq!(balance_after - balance_before, u256_to_big_dec(... | Rust | 0 |
name=input_dict.get("dataset").get("name"),
ordinal=input_dict.get("dataset").get("ordinal"),
),
implements_variable=(
SimpleImplementsVariable(
uid=input_dict.get("implements_variable").get("uid"),
name=input_di... | Python | 1 |
# Requires com.databricks:spark-xml_2.12:0.14.0
# TODO: normalize column names - remove `_`, switch to snake case
posts_schema = "`_AcceptedAnswerId` BIGINT, `_AnswerCount` int,`_Body` STRING,`_ClosedDate` TIMESTAMP,`_CommentCount` int,`_CommunityOwnedDate` TIMESTAMP,`_ContentLicense` STRING,`_CreationDate` TIMESTAMP... | Python | 1 |