FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
xarray/xarray/backends/memory.py at main · bhemmer/xarray · GitHub
bhemmer
/
xarray
Public
forked from
pydata/xarray
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
xarray
/
xarray
/
backends
/
memory.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (33 loc) · 1.3 KB
Breadcrumbs
xarray
/
xarray
/
backends
/
memory.py
Copy path
File metadata and controls
45 lines (33 loc) · 1.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
copy
import
numpy
as
np
from
..
core
.
variable
import
Variable
from
.
common
import
AbstractWritableDataStore
class
InMemoryDataStore
(
AbstractWritableDataStore
):
"""
Stores dimensions, variables and attributes in ordered dictionaries, making
this store fast compared to stores which save to disk.
This store exists purely for internal testing purposes.
"""
def
__init__
(
self
,
variables
=
None
,
attributes
=
None
):
self
.
_variables
=
{}
if
variables
is
None
else
variables
self
.
_attributes
=
{}
if
attributes
is
None
else
attributes
def
get_attrs
(
self
):
return
self
.
_attributes
def
get_variables
(
self
):
return
self
.
_variables
def
get_dimensions
(
self
):
dims
=
{}
for
v
in
self
.
_variables
.
values
():
for
d
,
s
in
v
.
dims
.
items
():
dims
[
d
]
=
s
return
dims
def
prepare_variable
(
self
,
k
,
v
,
*
args
,
**
kwargs
):
new_var
=
Variable
(
v
.
dims
,
np
.
empty_like
(
v
),
v
.
attrs
)
self
.
_variables
[
k
]
=
new_var
return
new_var
,
v
.
data
def
set_attribute
(
self
,
k
,
v
):
# copy to imitate writing to disk.
self
.
_attributes
[
k
]
=
copy
.
deepcopy
(
v
)
def
set_dimension
(
self
,
dim
,
length
,
unlimited_dims
=
None
):
# in this model, dimensions are accounted for in the variables
pass
Back
|
FazBrowse Home
|
New Git URL