Skip to content

Commit

Permalink
deploy: 3b87ba8
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Jul 19, 2024
1 parent 0031cbe commit 80f2ae4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
2 changes: 1 addition & 1 deletion numcodecs_python/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Rust-bindings for the `numcodecs` Python API using `pyo3`."><title>numcodecs_python - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-d7a46bd0e1dce774.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="numcodecs_python" data-themes="" data-resource-suffix="" data-rustdoc-version="1.81.0-nightly (5affbb171 2024-07-18)" data-channel="nightly" data-search-js="search-d234aafac6c221dd.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../numcodecs_python/index.html">numcodecs_python</a><span class="version">0.1.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></section></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">numcodecs_python</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/numcodecs_python/lib.rs.html#1-346">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Rust-bindings for the <a href="https://numcodecs.readthedocs.io/en/stable/"><code>numcodecs</code></a> Python API using <a href="https://docs.rs/pyo3/0.21/pyo3/"><code>pyo3</code></a>.</p>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Rust-bindings for the `numcodecs` Python API using `pyo3`."><title>numcodecs_python - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-d7a46bd0e1dce774.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="numcodecs_python" data-themes="" data-resource-suffix="" data-rustdoc-version="1.81.0-nightly (5affbb171 2024-07-18)" data-channel="nightly" data-search-js="search-d234aafac6c221dd.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../numcodecs_python/index.html">numcodecs_python</a><span class="version">0.1.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></section></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">numcodecs_python</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/numcodecs_python/lib.rs.html#1-360">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Rust-bindings for the <a href="https://numcodecs.readthedocs.io/en/stable/"><code>numcodecs</code></a> Python API using <a href="https://docs.rs/pyo3/0.21/pyo3/"><code>pyo3</code></a>.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Codec.html" title="struct numcodecs_python::Codec">Codec</a></div><div class="desc docblock-short">Represents a <a href="https://numcodecs.readthedocs.io/en/stable/abc.html#module-numcodecs.abc"><code>numcodecs.abc.Codec</code></a> <em>instance</em> object.</div></li><li><div class="item-name"><a class="struct" href="struct.CodecClass.html" title="struct numcodecs_python::CodecClass">CodecClass</a></div><div class="desc docblock-short">Represents a <a href="https://numcodecs.readthedocs.io/en/stable/abc.html#module-numcodecs.abc"><code>numcodecs.abc.Codec</code></a> <em>class</em> object.</div></li><li><div class="item-name"><a class="struct" href="struct.Registry.html" title="struct numcodecs_python::Registry">Registry</a></div><div class="desc docblock-short">Dynamic registry of codec classes.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.CodecClassMethods.html" title="trait numcodecs_python::CodecClassMethods">CodecClassMethods</a></div><div class="desc docblock-short">Methods implemented for <a href="struct.CodecClass.html" title="struct numcodecs_python::CodecClass"><code>CodecClass</code></a>es.</div></li><li><div class="item-name"><a class="trait" href="trait.CodecMethods.html" title="trait numcodecs_python::CodecMethods">CodecMethods</a></div><div class="desc docblock-short">Methods implemented for <a href="struct.Codec.html" title="struct numcodecs_python::Codec"><code>Codec</code></a>s.</div></li></ul></section></div></main></body></html>
56 changes: 42 additions & 14 deletions src/numcodecs_python/lib.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,20 @@
<a href="#344" id="344">344</a>
<a href="#345" id="345">345</a>
<a href="#346" id="346">346</a>
<a href="#347" id="347">347</a>
<a href="#348" id="348">348</a>
<a href="#349" id="349">349</a>
<a href="#350" id="350">350</a>
<a href="#351" id="351">351</a>
<a href="#352" id="352">352</a>
<a href="#353" id="353">353</a>
<a href="#354" id="354">354</a>
<a href="#355" id="355">355</a>
<a href="#356" id="356">356</a>
<a href="#357" id="357">357</a>
<a href="#358" id="358">358</a>
<a href="#359" id="359">359</a>
<a href="#360" id="360">360</a>
</pre></div><pre class="rust"><code><span class="doccomment">//! Rust-bindings for the [`numcodecs`] Python API using [`pyo3`].
//!
//! [`numcodecs`]: https://numcodecs.readthedocs.io/en/stable/
Expand Down Expand Up @@ -657,25 +671,24 @@
<span class="kw">let </span>config = PyDict::new_bound(py);
config.set_item(<span class="string">"id"</span>, <span class="string">"crc32"</span>)<span class="question-mark">?</span>;

<span class="kw">let </span>codec = Registry::get_codec(config.as_borrowed())<span class="question-mark">?</span>;
<span class="comment">// create a codec using registry lookup
</span><span class="kw">let </span>codec = Registry::get_codec(config.as_borrowed())<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(codec.class().codec_id()<span class="question-mark">?</span>, <span class="string">"crc32"</span>);

<span class="kw">let </span>data = <span class="kw-2">&amp;</span>[<span class="number">1_u8</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>];
<span class="comment">// re-register the codec class under a custom name
</span><span class="kw">let </span>class = codec.class();
Registry::register_codec(class, <span class="prelude-val">Some</span>(<span class="string">"my-crc32"</span>))<span class="question-mark">?</span>;
config.set_item(<span class="string">"id"</span>, <span class="string">"my-crc32"</span>)<span class="question-mark">?</span>;

<span class="kw">let </span>encoded = codec.encode(
numpy::PyArray1::from_slice_bound(py, data)
.as_any()
.as_borrowed(),
)<span class="question-mark">?</span>;
<span class="kw">let </span>decoded = codec.decode(encoded.as_borrowed(), <span class="prelude-val">None</span>)<span class="question-mark">?</span>;

<span class="kw">let </span>encoded: Vec&lt;u8&gt; = encoded.extract()<span class="question-mark">?</span>;
<span class="kw">let </span>decoded: Vec&lt;u8&gt; = decoded.extract()<span class="question-mark">?</span>;
<span class="comment">// create a codec using registry lookup of the custom name
</span><span class="kw">let </span>codec = Registry::get_codec(config.as_borrowed())<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(codec.class().codec_id()<span class="question-mark">?</span>, <span class="string">"crc32"</span>);

<span class="macro">assert_eq!</span>(encoded, [<span class="number">205</span>, <span class="number">251</span>, <span class="number">60</span>, <span class="number">182</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);
<span class="macro">assert_eq!</span>(decoded, data);
<span class="comment">// create a codec using the class
</span><span class="kw">let </span>codec = class.codec_from_config(config.as_borrowed())<span class="question-mark">?</span>;

<span class="kw">let </span>config = codec.get_config()<span class="question-mark">?</span>;
<span class="comment">// check the codec's config
</span><span class="kw">let </span>config = codec.get_config()<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(config.len(), <span class="number">1</span>);
<span class="macro">assert_eq!</span>(
config
Expand All @@ -686,6 +699,21 @@
<span class="prelude-val">Some</span>(<span class="string">"crc32"</span>)
);

<span class="comment">// encode and decode data with the codec
</span><span class="kw">let </span>data = <span class="kw-2">&amp;</span>[<span class="number">1_u8</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>];
<span class="kw">let </span>encoded = codec.encode(
numpy::PyArray1::from_slice_bound(py, data)
.as_any()
.as_borrowed(),
)<span class="question-mark">?</span>;
<span class="kw">let </span>decoded = codec.decode(encoded.as_borrowed(), <span class="prelude-val">None</span>)<span class="question-mark">?</span>;

<span class="comment">// check the encoded and decoded data
</span><span class="kw">let </span>encoded: Vec&lt;u8&gt; = encoded.extract()<span class="question-mark">?</span>;
<span class="kw">let </span>decoded: Vec&lt;u8&gt; = decoded.extract()<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(encoded, [<span class="number">205</span>, <span class="number">251</span>, <span class="number">60</span>, <span class="number">182</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);
<span class="macro">assert_eq!</span>(decoded, data);

<span class="prelude-val">Ok</span>(())
})
}
Expand Down

0 comments on commit 80f2ae4

Please sign in to comment.