-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
erroneous behavior on different machine (Windows) #45
Comments
This are the packages on my Mac, where all works: import numpy
import shapely
import simplification
import fiona
import geopandas
import json
import IPython
import altair
import ipywidgets # %load https://gist.github.com/kinverarity1/6038316/raw/loaded_modules.py
'''List loaded modules and packages, and show their version numbers
and/or Git repository's HEAD commit SHA.
'''
# Standard library modules
import types
import os
# Third-party packages
import git # GitPython
def module_path(mod):
'''Returns path to the file that module *mod* comes from.
If it doesn't come from a file, return None.'''
if hasattr(mod, '__file__'):
return os.path.abspath(os.path.dirname(mod.__file__))
else:
return None
def from_git_repo(mod):
'''Does the module *mod* reside in a Git repository?'''
path = module_path(mod)
if path:
try:
repo = git.Repo(path)
except:
return False
else:
return True
else:
return False
def git_path_sha(mod, slice=slice(0, 8, 1)):
'''Return SHA hash for the HEAD commit for the repository
that the module *mod* resides in.'''
repo = git.Repo(module_path(mod))
return repo.git_dir, repo.head.commit.hexsha[:8]
def module_version(mod):
'''Return version string for module *mod*, or nothing if
it doesn't have a "version" or "__version__" attribute.'''
version = []
if hasattr(mod, '__dict__'):
keys = []
for key in mod.__dict__.keys():
if key.lower() == 'version' or key.lower() == '__version__':
v = mod.__dict__[key]
if isinstance(v, str):
version.append(v)
if keys:
print(mod, keys)
if version:
return ', '.join(version)
else:
return ''
def find_loaded_modules(only_versioned_modules=True):
'''Return list of loaded modules for which there is a version
number or a Git repository commit SHA.
Return a list of *(name, version, path_to_git_repo, git_head_sha)*,
which has an HTML property for pretty display in IPython Notebooks.
'''
def list_of_lists_to_HTML(lists, header_row=None):
'''Convert a list of a list of strings to a HTML table.'''
s = '<table>'
if header_row:
s += '\n\t<tr>\n\t\t'
s += ''.join(['<th>%s</th>' % item for item in header_row])
s += '\n\t</tr>'
for inner_list in lists:
s += '\n\t<tr>\n\t\t'
s += ''.join(['<td>%s</td>' % item for item in inner_list])
s += '\n\t</tr>'
s += '\n</table>'
return s
class LoadedModules(list):
'''Very simple wrapper for a list of lists of strings, with an attribute
for display in IPython Notebooks.'''
def __init__(self, *args, **kwargs):
list.__init__(self, *args, **kwargs)
@property
def HTML(self):
from IPython.display import HTML
return HTML(
list_of_lists_to_HTML(
self, header_row=['Name', 'Version', 'Path', 'SHA']))
objs = LoadedModules()
for i, mod in enumerate(globals().values()):
if isinstance(mod, types.ModuleType):
if hasattr(mod, '__name__'):
name = mod.__name__
else:
name = ''
if from_git_repo(mod):
path, sha = git_path_sha(mod)
else:
path = ''
sha = ''
version = module_version(mod)
if only_versioned_modules:
flag = version or (path and sha)
else:
flag = True
if flag:
objs.append([mod.__name__, version, path, sha])
objs.sort(key=lambda r: r[0])
return objs find_loaded_modules().HTML
Let me check later how this look like on the different machine |
Some observations: tj = topojson.Topology(data, prequantize=False, topology=True)
tj.toposimplify(1).topoquantize(1e5).to_alt() So using |
See #49. The |
While testing on a different (windows) PC, I run into errors and different results:
Observe that the simplification only seems to have happened in Madagaskar:
Windows PC:

My Development PC:

From: https://nbviewer.jupyter.org/github/mattijn/topojson/blob/master/notebooks/ipywidgets_interaction.ipynb
Also this code from #43
Results in an error in the
dedup
step:..
The text was updated successfully, but these errors were encountered: