Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

bmcs-utils

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bmcs-utils - npm Package Compare versions

Comparing version
0.0.32a0
to
0.0.33a0
+15
bmcs_utils/config.py
# Backends are implemented as subclasses of PlotBackend
# and listed in a dictionary of plot_backends
# By default, matplotlib backend is enabled, to keep
# the list of dependencies small. Packages using bmcs_utils
# can specify the requied backends in the active_plot_backends
active_plot_backends = ['mpl']
from .plot_backend_mpl import MPLBackend
from .plot_backend_k3d import K3DBackend
available_plot_backends = \
{'mpl' : MPLBackend,
'k3d' : K3DBackend}
from .plot_backend import PlotBackend
import ipywidgets as ipw
class K3DBackend(PlotBackend):
"""Plotting backend for k3d
"""
def __init__(self, *args, **kw):
super().__init__(*args,**kw)
self.plot_widget = ipw.Output(layout=ipw.Layout(width="100%", height="100%"))
import k3d
self.plot_fig = k3d.Plot()
self.plot_fig.layout = ipw.Layout(width="100%",height="100%")
# with self.plot_widget:
# self.plot_fig.display()
self.plot_fig.outputs.append(self.plot_widget)
self.objects = {}
def clear_fig(self):
self.objects = {}
# while self.plot_fig.objects:
# self.plot_fig -= self.plot_fig.objects[-1]
self.plot_fig.objects = []
self.plot_fig.object_ids = []
def clear_object(self, object_key):
obj = self.objects[object_key]
if isinstance(obj, list):
objs = obj
for ob in objs:
self.plot_fig -= ob
else:
self.plot_fig -= obj
self.objects.pop(object_key)
def show_fig(self):
with self.plot_widget:
self.plot_fig.display()
def setup_plot(self, model):
model.setup_plot(self)
def update_plot(self, model):
model.update_plot(self)
from .plot_backend import PlotBackend
import matplotlib.pylab as plt
import ipywidgets as ipw
class MPLBackend(PlotBackend):
"""Plotting backend for matplotlib
"""
def __init__(self, *args, **kw):
super().__init__(*args,**kw)
# To prevent additional figure from showing in Jupyter when creating figure the first time with plt.figure
plt.ioff()
fig = plt.figure(tight_layout=True, *args, **kw)
fig.canvas.toolbar_position = 'top'
fig.canvas.header_visible = False
self.plot_widget = ipw.Output(layout=ipw.Layout(width="100%",height="100%"))
with self.plot_widget:
fig.show()
self.plot_fig = fig
def clear_fig(self):
pass
def show_fig(self):
self.plot_fig.show()
def setup_plot(self, model):
pass
def update_plot(self, model):
# plt.close() # suggestion: maybe needed to clear last openned fig from memory in jupyter
self.plot_fig.clf()
self.axes = model.subplots(self.plot_fig)
model.update_plot(self.axes)
import traits.api as tr
import ipywidgets as ipw
class PlotBackend(tr.HasTraits):
plot_widget = tr.Instance(ipw.Output)
plot_fig = tr.Any
+1
-1
Metadata-Version: 2.1
Name: bmcs-utils
Version: 0.0.32a0
Version: 0.0.33a0
Summary: Suite of utilities for to implementation of bmcs_utils for brittle-matrix composites.

@@ -5,0 +5,0 @@ Home-page: https://github.com/bmcs-group/bmcs_utils

@@ -7,2 +7,3 @@ README.md

bmcs_utils/app_window_example.py
bmcs_utils/config.py
bmcs_utils/controller.py

@@ -18,2 +19,5 @@ bmcs_utils/i_model.py

bmcs_utils/parametric_study.py
bmcs_utils/plot_backend.py
bmcs_utils/plot_backend_k3d.py
bmcs_utils/plot_backend_mpl.py
bmcs_utils/symb_expr.py

@@ -20,0 +24,0 @@ bmcs_utils/symb_expr_quad_example.py

@@ -5,2 +5,4 @@

import collections
collections.Iterable = collections.abc.Iterable
collections.Iterable = collections.abc.Iterable

@@ -13,84 +13,7 @@ '''

import traits.api as tr
import matplotlib.pyplot as plt
import k3d
from .tree_node import BMCSNode
from bmcs_utils.i_model import IModel
import bmcs_utils.config as config
print_output = ipw.Output(layout=ipw.Layout(width="100%"))
class PlotBackend(tr.HasTraits):
plot_widget = tr.Instance(ipw.Output)
plot_fig = tr.Any
class MPLBackend(PlotBackend):
"""Plotting backend for matplotlib
"""
def __init__(self, *args, **kw):
super().__init__(*args,**kw)
# To prevent additional figure from showing in Jupyter when creating figure the first time with plt.figure
plt.ioff()
fig = plt.figure(tight_layout=True, *args, **kw)
fig.canvas.toolbar_position = 'top'
fig.canvas.header_visible = False
self.plot_widget = ipw.Output(layout=ipw.Layout(width="100%",height="100%"))
with self.plot_widget:
fig.show()
self.plot_fig = fig
def clear_fig(self):
pass
def show_fig(self):
self.plot_fig.show()
def setup_plot(self, model):
pass
def update_plot(self, model):
# plt.close() # suggestion: maybe needed to clear last openned fig from memory in jupyter
self.plot_fig.clf()
self.axes = model.subplots(self.plot_fig)
model.update_plot(self.axes)
class K3DBackend(PlotBackend):
"""Plotting backend for k3d
"""
def __init__(self, *args, **kw):
super().__init__(*args,**kw)
self.plot_widget = ipw.Output(layout=ipw.Layout(width="100%", height="100%"))
self.plot_fig = k3d.Plot()
self.plot_fig.layout = ipw.Layout(width="100%",height="100%")
# with self.plot_widget:
# self.plot_fig.display()
self.plot_fig.outputs.append(self.plot_widget)
self.objects = {}
def clear_fig(self):
self.objects = {}
# while self.plot_fig.objects:
# self.plot_fig -= self.plot_fig.objects[-1]
self.plot_fig.objects = []
self.plot_fig.object_ids = []
def clear_object(self, object_key):
obj = self.objects[object_key]
if isinstance(obj, list):
objs = obj
for ob in objs:
self.plot_fig -= ob
else:
self.plot_fig -= obj
self.objects.pop(object_key)
def show_fig(self):
with self.plot_widget:
self.plot_fig.display()
def setup_plot(self, model):
model.setup_plot(self)
def update_plot(self, model):
model.update_plot(self)
class AppWindow(tr.HasTraits):

@@ -111,3 +34,4 @@ '''Container class synchronizing the interactionjup elements with plotting area.

def _plot_backend_table_default(self):
return{'mpl': MPLBackend(), 'k3d': K3DBackend()}
return {key : config.available_plot_backends[key]() for key
in config.active_plot_backends}

@@ -114,0 +38,0 @@ # Shared layouts -

@@ -5,2 +5,3 @@

from .tree_node import BMCSNode
from .trait_types import TraitBase

@@ -26,2 +27,4 @@ class ModelTreeNodeMixin(tr.HasTraits):

trait_type = trait.trait_type
if not isinstance(trait_type, TraitBase):
raise Exception('type error of attribute: {} - {} '.format(name, str(trait_type)))
name_ = trait_type.get_name_(name)

@@ -28,0 +31,0 @@ trait_ = getattr(self, name_, None)

@@ -1,1 +0,1 @@

__version__='0.0.32a'
__version__='0.0.33a'
Metadata-Version: 2.1
Name: bmcs_utils
Version: 0.0.32a0
Version: 0.0.33a0
Summary: Suite of utilities for to implementation of bmcs_utils for brittle-matrix composites.

@@ -5,0 +5,0 @@ Home-page: https://github.com/bmcs-group/bmcs_utils