-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcf.hash_array.html
More file actions
208 lines (169 loc) · 12.7 KB
/
cf.hash_array.html
File metadata and controls
208 lines (169 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>cf.hash_array — Documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=61cd365c" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css?v=a5d0ad34" />
<link rel="stylesheet" type="text/css" href="../_static/graphviz.css?v=fd3f3429" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../_static/customise-alabaster.css?v=5dec66a6" />
<script src="../_static/documentation_options.js?v=b14d8abf"></script>
<script src="../_static/doctools.js?v=9a2dae69"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../_static/copybutton.js?v=b578dfe4"></script>
<script src="../_static/toggleprompt.js?v=1b41717f"></script>
<link rel="icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="cf.min_total_memory" href="cf.min_total_memory.html" />
<link rel="prev" title="cf.free_memory_factor" href="cf.free_memory_factor.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/logo.svg" alt="Logo"/>
</a></p>
<h1 class="logo"><a href="../index.html">cf 3.19.0</a></h1>
<p class="blurb">A CF-compliant earth science data analysis library</p>
<p>
<iframe src="https://ghbtns.com/github-btn.html?user=NCAS-CMS&repo=cf-python&type=star&count=true&size=large&v=2"
allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px"></iframe>
</p>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../introduction.html"><strong>Introduction</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../installation.html"><strong>Installation</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../cheat_sheet.html"><strong>Cheat Sheet</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../recipes/index.html"><strong>Recipes using cf</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial.html"><strong>Tutorial</strong></a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../api_reference.html"><strong>API reference</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../aggregation_rules.html"><strong>Aggregation rules</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../performance.html"><strong>Performance</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../releases.html"><strong>Releases</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../Changelog.html"><strong>Change log</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html"><strong>Contributing</strong></a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li><a href="../api_reference.html"><strong>API reference</strong></a><ul>
<li><a href="../function.html"><strong>cf functions</strong></a><ul>
<li>Previous: <a href="cf.free_memory_factor.html" title="previous chapter">cf.free_memory_factor</a></li>
<li>Next: <a href="cf.min_total_memory.html" title="next chapter">cf.min_total_memory</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
</div>
<br>
cf development has been supported by
the <a href="https://erc.europa.eu/">ERC</a>
through <a href="https://cordis.europa.eu/project/id/247220">Seachange</a>
and
<a href="https://cordis.europa.eu/project/id/786427">Couplet</a>; by
the <a href="https://ec.europa.eu/programmes/horizon2020/">EC Horizon
2020 programme</a> through
<a href="https://cordis.europa.eu/project/id/824084">IS-ENES3</a>;
by <a href="https://nerc.ukri.org/">NERC</a> through
<a href="https://gtr.ukri.org/project/0D95A6DB-0B95-48F7-8A8B-7B9A47DEA117">UKFAFMIP</a>;
and by <a href="https://ncas.ac.uk/">NCAS</a>.
<br>
<br>
<img src="../_static/logo_EC.png" height="40">
<img src="../_static/logo_ERC.png" height="40">
<img src="../_static/logo_NERC.png" height="40">
<br>
<img src="../_static/logo_NCAS.png" height="40">
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="cf-hash-array">
<h1>cf.hash_array<a class="headerlink" href="#cf-hash-array" title="Link to this heading">¶</a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="cf.hash_array">
<span class="sig-prename descclassname"><span class="pre">cf.</span></span><span class="sig-name descname"><span class="pre">hash_array</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">algorithm</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/NCAS-CMS/cf-python/blob/v3.19.0/cf/functions.py#L2830-L2886"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#cf.hash_array" title="Link to this definition">¶</a></dt>
<dd><p>Return a hash value of a numpy array.</p>
<p>Deprecated at version 3.15.0 and is no longer available. Use
<code class="xref py py-obj docutils literal notranslate"><span class="pre">dask.base.tokenize</span></code> instead.</p>
<p>The hash value is dependent on the data type and the shape of the
array. If the array is a masked array then the hash value is
independent of the fill value and of data array values underlying
any masked elements.</p>
<dl class="field-list">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><dl>
<dt>array: <a class="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="(in NumPy v2.4)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">numpy.ndarray</span></code></a></dt><dd><p>The numpy array to be hashed. May be a masked array.</p>
</dd>
<dt>algorithm: <a class="reference external" href="https://docs.python.org/3/library/hashlib.html#module-hashlib" title="(in Python v3.14)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">hashlib</span></code></a> constructor function</dt><dd><p>Constructor function for the desired hash algorithm,
e.g. <a class="reference external" href="https://docs.python.org/3/library/hashlib.html#hashlib.md5" title="(in Python v3.14)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">hashlib.md5</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/hashlib.html#hashlib.sha256" title="(in Python v3.14)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">hashlib.sha256</span></code></a>, etc.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.14.0.</span></p>
</div>
</dd>
</dl>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><dl class="simple">
<dt><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.14)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">int</span></code></a></dt><dd><p>The hash value.</p>
</dd>
</dl>
</dd>
</dl>
<p><strong>Examples</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]])</span>
<span class="gp">>>> </span><span class="n">cf</span><span class="o">.</span><span class="n">hash_array</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="go">-5620332080097671134</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ma</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]],</span> <span class="n">mask</span><span class="o">=</span><span class="p">[[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]])</span>
<span class="gp">>>> </span><span class="n">cf</span><span class="o">.</span><span class="n">hash_array</span><span class="p">(</span><span class="n">array</span><span class="p">)</span>
<span class="go">8372868545804866378</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mi">999</span>
<span class="gp">>>> </span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ma</span><span class="o">.</span><span class="n">masked</span>
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="go">[[0 -- 2 3]]</span>
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">a</span><span class="o">.</span><span class="n">data</span><span class="p">)</span>
<span class="go">[[ 0 999 2 3]]</span>
<span class="gp">>>> </span><span class="n">cf</span><span class="o">.</span><span class="n">hash_array</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="go">8372868545804866378</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">a</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">cf</span><span class="o">.</span><span class="n">hash_array</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="go">5950106833921144220</span>
</pre></div>
</div>
</dd></dl>
</section>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©2026, NCAS | Page built on 2026-01-19.
|
Powered by <a href="https://www.sphinx-doc.org/">Sphinx 7.3.7</a>
& <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>
</div>
</body>
</html>