xplr 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
xplr-0.0.1/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2026 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
xplr-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.5
2
+ Name: xplr
3
+ Version: 0.0.1
4
+ Summary: Quick visualization of Python objects for exploratory data analysis
5
+ Project-URL: Homepage, https://github.com/michaeldorman/xplr/
6
+ Project-URL: Issues, https://github.com/michaeldorman/xplr/issues
7
+ Author-email: Michael Dorman <dorman@post.bgu.ac.il>
8
+ License: Copyright (c) 2026 The Python Packaging Authority
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ License-File: LICENSE
28
+ Classifier: Operating System :: OS Independent
29
+ Classifier: Programming Language :: Python :: 3
30
+ Requires-Python: >=3.12
31
+ Description-Content-Type: text/markdown
32
+
33
+ # `xplr`
34
+
35
+ [![badge](https://img.shields.io/pypi/v/xplr)](https://pypi.org/project/xplr/)
36
+
37
+ ## Overview
38
+
39
+ The `xplr` package
40
+
41
+ ## Import on startup
42
+
43
+ Create a startup script, such as `~/.python_startup.py`:
44
+
45
+ ```python
46
+ from xplr import plot
47
+ from xplr import view
48
+ ```
49
+
50
+ For the script to be automatically executed on `python` startup, add this in your `.bashrc`:
51
+
52
+ ```python
53
+ export PYTHONSTARTUP=~/.python_startup.py
54
+ ```
55
+
56
+ In addition, for the script to be automatically executed on `ipython` startup, create ipython profiles (if you don't already have them):
57
+
58
+ ```python
59
+ ipython profile create
60
+ ```
61
+
62
+ Then, uncomment the following expression in `~/.ipython/profile_default/ipython_config.py`:
63
+
64
+ ```python
65
+ c.InteractiveShellApp.exec_PYTHONSTARTUP = True
66
+ ```
67
+
68
+
xplr-0.0.1/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # `xplr`
2
+
3
+ [![badge](https://img.shields.io/pypi/v/xplr)](https://pypi.org/project/xplr/)
4
+
5
+ ## Overview
6
+
7
+ The `xplr` package
8
+
9
+ ## Import on startup
10
+
11
+ Create a startup script, such as `~/.python_startup.py`:
12
+
13
+ ```python
14
+ from xplr import plot
15
+ from xplr import view
16
+ ```
17
+
18
+ For the script to be automatically executed on `python` startup, add this in your `.bashrc`:
19
+
20
+ ```python
21
+ export PYTHONSTARTUP=~/.python_startup.py
22
+ ```
23
+
24
+ In addition, for the script to be automatically executed on `ipython` startup, create ipython profiles (if you don't already have them):
25
+
26
+ ```python
27
+ ipython profile create
28
+ ```
29
+
30
+ Then, uncomment the following expression in `~/.ipython/profile_default/ipython_config.py`:
31
+
32
+ ```python
33
+ c.InteractiveShellApp.exec_PYTHONSTARTUP = True
34
+ ```
35
+
36
+
@@ -0,0 +1,28 @@
1
+ [build-system]
2
+ requires = [
3
+ "hatchling >= 1.26",
4
+ "geopandas >= 1.1.0",
5
+ "rasterio >= 1.4.0",
6
+ ]
7
+ build-backend = "hatchling.build"
8
+
9
+ [project]
10
+ name = "xplr"
11
+ version = "0.0.1"
12
+ authors = [
13
+ { name="Michael Dorman", email="dorman@post.bgu.ac.il" },
14
+ ]
15
+ description = "Quick visualization of Python objects for exploratory data analysis"
16
+ readme = "README.md"
17
+ requires-python = ">=3.12"
18
+ classifiers = [
19
+ "Programming Language :: Python :: 3",
20
+ "Operating System :: OS Independent",
21
+ ]
22
+
23
+ [project.license]
24
+ file = "LICENSE"
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/michaeldorman/xplr/"
28
+ Issues = "https://github.com/michaeldorman/xplr/issues"
@@ -0,0 +1,2 @@
1
+ from .xplr import plot
2
+ from .xplr import view
@@ -0,0 +1,83 @@
1
+ def open_file_with_default_app(file_path):
2
+ import os
3
+ import platform
4
+ import subprocess
5
+ """Opens a file using the operating system's default application."""
6
+ # Clean env
7
+ env = os.environ.copy()
8
+ for var in ['VIRTUAL_ENV', 'PYTHONHOME', 'PYTHONPATH']:
9
+ env.pop(var, None)
10
+ if 'VIRTUAL_ENV' in os.environ:
11
+ venv_bin = os.path.join(os.environ['VIRTUAL_ENV'], 'bin')
12
+ env['PATH'] = ':'.join(
13
+ p for p in env['PATH'].split(':') if p != venv_bin
14
+ )
15
+ # Run
16
+ current_os = platform.system().lower()
17
+ abs_path = os.path.abspath(file_path)
18
+ if current_os == 'windows':
19
+ os.startfile(abs_path)
20
+ elif current_os == 'darwin':
21
+ subprocess.call(('open', abs_path), stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
22
+ else:
23
+ subprocess.call(('xdg-open', abs_path), env=env, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
24
+
25
+ def plot(x, *args, **kwargs):
26
+ import matplotlib.pyplot as plt
27
+ plt.ion()
28
+ import pandas as pd
29
+ import geopandas as gpd
30
+ import numpy as np
31
+ import rasterio.plot
32
+ # GeoDataFrame
33
+ if isinstance(x, gpd.GeoDataFrame):
34
+ x.plot(legend=True, *args, **kwargs)
35
+ return
36
+ # DataFrame
37
+ if isinstance(x, pd.DataFrame):
38
+ x.plot(*args, **kwargs)
39
+ return
40
+ # Series
41
+ if isinstance(x, pd.Series):
42
+ x.plot(*args, **kwargs)
43
+ return
44
+ # Array 1d
45
+ if isinstance(x, np.ndarray) and x.ndim == 1:
46
+ plt.plot(x, *args, **kwargs)
47
+ return
48
+ # Array 2d
49
+ if isinstance(x, np.ndarray) and x.ndim == 2:
50
+ plt.imshow(x, *args, **kwargs)
51
+ return
52
+
53
+ def view(x) -> str:
54
+ import os
55
+ import subprocess
56
+ import tempfile
57
+ import pandas as pd
58
+ import geopandas as gpd
59
+ """
60
+ Exports an object to a temporary file and opens it in external program.
61
+
62
+ Args:
63
+ x: The object to view.
64
+
65
+ Returns:
66
+ The path to the temporary file (it persists until the OS cleans it up).
67
+ """
68
+ # Vector layer
69
+ if isinstance(x, gpd.GeoSeries) or isinstance(x, gpd.GeoDataFrame):
70
+ with tempfile.NamedTemporaryFile(suffix='.gpkg', delete=False) as tmp:
71
+ tmp_path = tmp.name
72
+ x.to_file(tmp_path, index=False)
73
+ open_file_with_default_app(tmp_path)
74
+ return tmp_path
75
+ # Table
76
+ if isinstance(x, pd.Series) or isinstance(x, pd.DataFrame):
77
+ with tempfile.NamedTemporaryFile(suffix='.xlsx', delete=False) as tmp:
78
+ tmp_path = tmp.name
79
+ x.to_excel(tmp_path, index=False)
80
+ open_file_with_default_app(tmp_path)
81
+ return tmp_path
82
+
83
+