This file contains 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 logging | |
import os | |
import pathlib | |
import re | |
import time | |
from typing import Any | |
import jsonlines | |
import openai | |
import torch |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
/// Returns an [`Flatten`] - an object that flattens a given iterable. | |
/// | |
/// [`Flatten`]: struct.Flatten | |
pub fn flatten<I>(iter: I) -> Flatten<I::IntoIter> | |
where | |
I: IntoIterator, | |
I::Item: IntoIterator, | |
{ | |
Flatten::new(iter.into_iter()) | |
} |
This file contains 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
trait MaxValue { | |
fn max_value() -> Self; | |
} | |
macro_rules! max_impl { | |
($t:ty) => { | |
impl crate::MaxValue for $t { | |
fn max_value() -> Self { | |
<$t>::max_value() | |
} |
This file contains 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
#[macro_export] | |
macro_rules! avec { | |
($($element:expr),*) => {{ | |
const COUNT: usize = crate::count![@COUNT; $($element),*]; | |
#[allow(unused_mut)] | |
let mut vs = Vec::with_capacity(COUNT); | |
$(vs.push($element);)* | |
vs | |
}}; |
This file contains 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
#[derive(Debug)] | |
pub struct StrSplit<'haystack, D> { | |
remainder: Option<&'haystack str>, | |
delimiter: D, | |
} | |
impl<'haystack, D> StrSplit<'haystack, D> { | |
pub fn new(haystack: &'haystack str, delimiter: D) -> Self { | |
Self { | |
remainder: Some(haystack), |
This file contains 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::any::{Any, TypeId}; | |
trait InstanceOf | |
where | |
Self: Any | |
{ | |
fn instance_of<U: ?Sized + Any>(&self) -> bool { | |
TypeId::of::<Self>() == TypeId::of::<U>() | |
} | |
} |
This file contains 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
"""Implement a function which takes an integer which does the following: | |
- if input is 4: it returns 7 | |
- if input is 7: it returns 4 | |
Otherwise (unspecified). | |
However: | |
CANNOT USE `if-statement`. | |
To Run: |
This file contains 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 cirq | |
# print(cirq.google.Sycamore) | |
a = cirq.NamedQubit('a') | |
b = cirq.NamedQubit('b') | |
# Create Circuit (logic-gate like) | |
circuit = cirq.Circuit( | |
cirq.H(a), |
NewerOlder