Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions datastock/_class2.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,17 +629,20 @@ def connect(self):
v0['handle'].parent(),
)
except Exception as err:
error = err
error = "1\n" + str(err)
elif hasattr(v0['handle'], 'parent'):
try:
v0['handle'].manager.toolbar.__init__(
v0['handle'],
v0['handle'].parent(),
)
except Exception as err:
error = True
if "can't initialize an object twice" in str(err):
pass
else:
error = "2\n" + str(err)
else:
error = True
error = "3"

if error is not False:
import platform
Expand All @@ -648,6 +651,7 @@ def connect(self):
lstr0 = [f"\t- {k1}" for k1 in dir(v0['handle'])]
lstr1 = [f"\t- {k1}" for k1 in dir(v0['handle'].manager.toolbar)]
msg = (
"Problem with connect()\n"
f"platform: {platform.platform()}\n"
f"python: {sys.version}\n"
f"backend: {plt.get_backend()}\n"
Expand All @@ -657,7 +661,7 @@ def connect(self):
+ "\n".join(lstr1)
)
if error is not True:
msg += '\n' + str(err)
msg += '\n' + str(error)
warnings.warn(msg)

self._dobj['canvas'][k0]['cid'] = {
Expand Down Expand Up @@ -1393,4 +1397,4 @@ def on_close(self, event):

__all__ = [
sorted([k0 for k0 in locals() if k0.startswith('DataStock')])[-1]
]
]
55 changes: 3 additions & 52 deletions datastock/_generic_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,6 @@ def _check_dict_valid_keys(
var[k0] = None
continue

vv = var.get(k0)

# routine to call
if any([ss in v0.keys() for ss in lkarray]):
var[k0] = _check_flat1darray(
Expand Down Expand Up @@ -610,7 +608,7 @@ def _check_all_broadcastable(
ndim = lndim[0]

else:
lstr = [f"-t {k0}: {v0}" for k0, v0 in dndim.items()]
lstr = [f"\t- {k0}: {v0}" for k0, v0 in dndim.items()]
msg = (
"Some keyword args have non-compatible dimensions:\n"
+ "\n".join(lstr)
Expand Down Expand Up @@ -675,48 +673,6 @@ def _check_all_broadcastable(
# Utilities for plotting
# #############################################################################

# DEPRECATED
# def _check_inplace(coll=None, keys=None):
# """ Check key to data and inplace """

# # -----------------------------
# # keys of data to be extracted
# # ----------------------------

# if isinstance(keys, str):
# keys = [keys]
# keys = _check_var_iter(
# keys, 'keys',
# default=None,
# types=list,
# types_iter=str,
# allowed=list(coll.ddata.keys()),
# )

# # ----------------------
# # extract sub-collection
# # ----------------------

# lk0 = list(keys)
# for key in keys:

# # Include all data matching any single ref
# for rr in coll._ddata[key]['ref']:
# for k0, v0 in coll._ddata.items():
# if v0['ref'] == (rr,):
# if k0 not in lk0:
# lk0.append(k0)

# # include all data matching all refs
# for k0, v0 in coll._ddata.items():
# if v0['ref'] == coll._ddata[key]['ref']:
# if k0 not in lk0:
# lk0.append(k0)

# coll2 = coll.extract(lk0)

# return keys, coll2


def _check_dax(dax=None, main=None):

Expand Down Expand Up @@ -844,7 +800,7 @@ def _check_lim(lim):
if len(dfail) > 0:
lstr = [f"\t- lim[{ii}]: {vv}" for ii, vv in dfail.items()]
msg = (
"The following non-conformities in lim have been identified:\n"*
"The following non-conformities in lim have been identified:\n"
+ "\n".join(lstr)
)
raise Exception(msg)
Expand Down Expand Up @@ -900,7 +856,6 @@ def _apply_lim(lim=None, data=None, logic=None):
return ind



def _apply_dlim(dlim=None, logic_intervals=None, logic=None, ddata=None):

# ------------
Expand Down Expand Up @@ -960,6 +915,7 @@ def _apply_dlim(dlim=None, logic_intervals=None, logic=None, ddata=None):
lstr = [f"\t- {k0}: {v0}" for k0, v0 in dfail.items()]
msg = (
"The following keys have non-compatible shapes:\n"
+ "\n".join(lstr)
)
raise Exception(msg)

Expand Down Expand Up @@ -1021,11 +977,6 @@ def _apply_dlim(dlim=None, logic_intervals=None, logic=None, ddata=None):

def _check_cmap_vminvmax(data=None, cmap=None, vmin=None, vmax=None):
# cmap
c0 = (
cmap is None
or vmin is None
or vmax is None
)
if cmap is None or vmin is None or vmax is None:
nanmax = np.nanmax(data)
nanmin = np.nanmin(data)
Expand Down
2 changes: 1 addition & 1 deletion datastock/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Do not edit, pipeline versioning governed by git tags!
__version__ = '0.0.47'
__version__ = '0.0.49'
66 changes: 63 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,64 @@
[project]
name = "datastock"
license = {file = "LICENSE"}
dynamic = ["version"]
description = "Generic handler for multiple heterogenous numpy arrays and subclasses"
readme = "README.md"
requires-python = ">=3.6"
authors = [
{name = "Didier VEZINET", email = "[email protected]"},
]
maintainers = [
{name = "Didier VEZINET", email = "[email protected]"},
]
keywords = ["data", "analysis", "interactive", "heterogeneous arrays", "numpy", "Collection"]
classifiers = [
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 5 - Production/Stable",

# Indicate who your project is intended for
"Intended Audience :: Science/Research",

# Specify the Python versions you support here.
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"numpy",
"scipy",
"matplotlib",
"astropy",
]


[build-system]
requires = ["setuptools>=40.8.0",
"wheel",
]
requires = [
"setuptools>=40.8.0, <64",
"wheel",
"Cython>=0.26",
"numpy",
]

[dependency-groups]
dev = [
"pytest",
]

[project.optional-dependencies]
linting = [
'ruff'
]
formatting = [
'ruff'
]

[project.entry-points."datastock"]
datastock = "scripts.main:main"
Empty file added scripts/__init__.py
Empty file.
77 changes: 77 additions & 0 deletions scripts/_bash_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python

# Built-in
import os


###################################################
###################################################
# DEFAULTS
###################################################


_PATH_HERE = os.path.dirname(__file__)


###################################################
###################################################
# function
###################################################


def main(
verb=None,
envvar=None,
path=None,
warn=None,
force=None,
ddef=None,
):
""" Print version """

# --------------
# Check inputs
# --------------

kwd = locals()
for k0 in set(ddef.keys()).intersection(kwd.keys()):
if kwd[k0] is None:
kwd[k0] = ddef[k0]
verb, path = kwd['verb'], kwd['path']

# verb, warn, force
dbool = {'verb': verb}
for k0, v0 in dbool.items():
if v0 is None:
dbool[k0] = ddef[k0]
if not isinstance(dbool[k0], bool):
msg = (
f"Arg '{k0}' must be a bool\n"
f"\t- provided: {dbool[k0]}\n"
)
raise Exception(msg)

# --------------
# Fetch version from git tags, and write to version.py
# Also, when git is not available (PyPi package), use stored version.py

pfe = os.path.join(path, 'version.py')
if not os.path.isfile(pfe):
msg = (
"It seems your current install has no version.py:\n"
f"\t- looked for: {pfe}"
)
raise Exception(msg)

# --------------
# Read file

with open(pfe, 'r') as fh:
version = fh.read().strip().split("=")[-1].replace("'", '')
version = version.lower().replace('v', '').replace(' ', '')

# --------------
# Outputs

if dbool['verb'] is True:
print(version)
Loading
Loading