bmcs-utils
Advanced tools
| Metadata-Version: 2.1 | ||
| Name: bmcs-utils | ||
| Version: 0.0.32a1 | ||
| Version: 0.0.35a0 | ||
| 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 |
@@ -1,17 +0,8 @@ | ||
| .gitignore | ||
| README.md | ||
| __init__.py | ||
| bmcs_devel_environment.yml | ||
| environment.yml | ||
| main.py | ||
| meta.yaml | ||
| requirements.txt | ||
| setup.py | ||
| bmcs_utils/__init__.py | ||
| bmcs_utils/api.py | ||
| bmcs_utils/app_window.ipynb | ||
| bmcs_utils/app_window.py | ||
| bmcs_utils/app_window_example.py | ||
| bmcs_utils/controller.py | ||
| bmcs_utils/design.ipynb | ||
| bmcs_utils/i_model.py | ||
@@ -39,22 +30,7 @@ bmcs_utils/item.py | ||
| bmcs_utils/demo/app_window.py | ||
| bmcs_utils/demo/index.ipynb | ||
| bmcs_utils/demo/layout_model.py | ||
| bmcs_utils/demo/model_elementary.ipynb | ||
| bmcs_utils/demo/model_notify_mixin.ipynb | ||
| bmcs_utils/demo/model_raise_exception.ipynb | ||
| bmcs_utils/demo/model_tree.ipynb | ||
| bmcs_utils/demo/model_with_either_type_depends_on.ipynb | ||
| bmcs_utils/demo/model_with_either_type_tree.ipynb | ||
| bmcs_utils/demo/model_with_enum.ipynb | ||
| bmcs_utils/demo/model_with_history_slider.ipynb | ||
| bmcs_utils/demo/model_with_history_slider.py | ||
| bmcs_utils/demo/model_with_instance_property.ipynb | ||
| bmcs_utils/demo/model_with_list_editor.ipynb | ||
| bmcs_utils/demo/model_with_progress_bar.ipynb | ||
| bmcs_utils/demo/model_with_progress_bar.py | ||
| bmcs_utils/demo/model_with_selector_depends_on.ipynb | ||
| bmcs_utils/demo/model_with_volume.ipynb | ||
| bmcs_utils/demo/model_with_volume.py | ||
| bmcs_utils/demo/shape_model.py | ||
| bmcs_utils/demo/tree_extract.ipynb | ||
| bmcs_utils/editors/__init__.py | ||
@@ -75,3 +51,2 @@ bmcs_utils/editors/dict_editor.py | ||
| bmcs_utils/misc/__init__.py | ||
| bmcs_utils/misc/exp_data_tools.py | ||
| bmcs_utils/misc/plot_tools.py | ||
@@ -87,22 +62,2 @@ bmcs_utils/trait_types/__init__.py | ||
| bmcs_utils/trait_types/trait_types.py | ||
| bmcs_utils/trait_types/weakref_type.py | ||
| docs/README.md | ||
| docs/distribution.md | ||
| docs/jupyter_access.md | ||
| docs/python_access.md | ||
| docs/questions_and_answers.md | ||
| docs/state_change_dependencies.md | ||
| docs/webapp_access.md | ||
| docs/images/my_python_packages.png | ||
| docs/images/pycharm_project_interpreter_1.png | ||
| docs/images/pycharm_project_interpreter_2.png | ||
| figures/.~lock.S0602 - Energy dissipation.odp# | ||
| figures/S0602 - Energy dissipation.odp | ||
| notebooks/dynamic_widget_box.ipynb | ||
| notebooks/implementation_of_interactive_model.ipynb | ||
| notebooks/ipytree.ipynb | ||
| notebooks/k3d_plot_test.ipynb | ||
| notebooks/model_development_patterns.ipynb | ||
| notebooks/sinus_interactive_plot_widget.ipynb | ||
| notebooks/test_nbstripout.ipynb | ||
| notebooks/theano_numpy_test.ipynb | ||
| bmcs_utils/trait_types/weakref_type.py |
@@ -0,0 +0,0 @@ |
@@ -20,4 +20,3 @@ | ||
| HistoryEditor, TextAreaEditor, IntRangeEditor, FloatSliderEditorSelector, FloatSliderEditor | ||
| from bmcs_utils.misc.exp_data_tools import get_fw_curves_avg, get_asc_upper_env_ids, get_exp_fw_asc | ||
| from bmcs_utils.misc.plot_tools import plot_colors, set_latex_mpl_format, get_color | ||
| from bmcs_utils.misc.plot_tools import plot_colors, set_latex_mpl_format | ||
| from bmcs_utils.parametric_study import ParametricStudy | ||
@@ -27,2 +26,3 @@ from bmcs_utils.data_cache import data_cache | ||
| from bmcs_utils.k3d_utils.k3d_utils import K3DUtils | ||
| from bmcs_utils.symbol.cymbol import Cymbol, cymbols, ccode | ||
@@ -0,0 +0,0 @@ |
@@ -64,4 +64,4 @@ ''' | ||
| self.plot_fig.layout = ipw.Layout(width="100%",height="100%") | ||
| with self.plot_widget: | ||
| self.plot_fig.display() | ||
| # with self.plot_widget: | ||
| # self.plot_fig.display() | ||
| self.plot_fig.outputs.append(self.plot_widget) | ||
@@ -89,5 +89,4 @@ self.objects = {} | ||
| def show_fig(self): | ||
| # calling self.plot_fig.display() here will add new k3d interface each time a parameter changes | ||
| pass | ||
| with self.plot_widget: | ||
| self.plot_fig.display() | ||
| def setup_plot(self, model): | ||
@@ -94,0 +93,0 @@ model.setup_plot(self) |
@@ -0,0 +0,0 @@ import traits.api as tr |
| from .data_cache import data_cache |
@@ -0,0 +0,0 @@ #------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ """ |
@@ -0,0 +0,0 @@ from bmcs_utils.trait_types import \ |
@@ -0,0 +0,0 @@ from bmcs_utils.trait_types import \ |
@@ -0,0 +0,0 @@ from bmcs_utils.trait_types import \ |
@@ -0,0 +0,0 @@ from bmcs_utils.trait_types import \ |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ |
@@ -275,4 +275,3 @@ import traits.api as tr | ||
| tooltip=self.tooltip, | ||
| icon=self.icon, # (FontAwesome names without the `fa-` prefix) | ||
| style=style, | ||
| icon=self.icon # (FontAwesome names without the `fa-` prefix) | ||
| ) | ||
@@ -279,0 +278,0 @@ |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ import traits.api as tr |
@@ -18,6 +18,6 @@ | ||
| max_value = tr.Float(1) | ||
| step_value = tr.Float(0.01) | ||
| step = tr.Float(0.01) | ||
| min_var = tr.Str('') | ||
| max_var = tr.Str('') | ||
| step_var = tr.Str('') | ||
| step = tr.Str('') | ||
@@ -47,6 +47,6 @@ tooltip = tr.Property(depends_on='time_var, time_max_var') | ||
| def _get_step(self): | ||
| if self.step_var == '': | ||
| step = self.step_value | ||
| if self.step == '': | ||
| step = self.step | ||
| else: | ||
| step = getattr(self.model, str(self.step_var)) | ||
| step = getattr(self.model, str(self.step)) | ||
| return step | ||
@@ -62,8 +62,10 @@ | ||
| var = str(self.var).split('.')[-1] | ||
| eta = (getattr(self.submodel, var) - self.t_min) / (self.t_max - self.t_min) | ||
| t_span = self.t_max - self.t_min | ||
| eta = (getattr(self.submodel, var) - self.t_min) / t_span | ||
| t_value = eta * t_span + self.t_min | ||
| self.history_slider = ipw.FloatSlider( | ||
| value=eta, | ||
| min=0, | ||
| max=1, | ||
| step=self.step, | ||
| min=self.t_min, | ||
| max=self.t_max, | ||
| step=0.01 * t_span, | ||
| tooltip=self.tooltip, | ||
@@ -70,0 +72,0 @@ continuous_update=False, |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ |
+4
-13
@@ -21,6 +21,5 @@ | ||
| editor = self.editor | ||
| elif trait.trait_type.editor_factory is None: | ||
| raise TypeError(f'no editor attribute {self.name} in {model}, maybe not declared?') | ||
| else: | ||
| # create a new edior using the factory provided by the trait type | ||
| if trait.trait_type.editor_factory is None: | ||
| raise TypeError('no editor for %s with type %s' % (self.name,trait.trait_type) ) | ||
| editor = trait.trait_type.editor_factory() | ||
@@ -31,12 +30,4 @@ # use the editor supplied in the item defintion and set its attributes | ||
| if not editor.label: | ||
| if self.latex: | ||
| editor.label = r'\(%s\)' % self.latex | ||
| else: | ||
| editor.label = self.name | ||
| desc = trait.desc | ||
| if desc: | ||
| editor.tooltip = desc | ||
| else: | ||
| editor.tooltip = self.name | ||
| editor.label = r'\(%s\)' % self.latex if self.latex else self.name | ||
| editor.tooltip = desc if (desc := trait.desc) else self.name | ||
| editor.value = value | ||
@@ -43,0 +34,0 @@ editor.trait = trait |
@@ -0,0 +0,0 @@ """ |
@@ -0,0 +0,0 @@ import bmcs_utils.api as bu |
| import matplotlib.pyplot as plt | ||
| import numpy as np | ||
| plot_colors = ['#000000', | ||
| '#bc2122', | ||
| '#1f77b4', | ||
| '#ff7f0e', | ||
| '#2ca02c', | ||
| '#9467bd', | ||
| '#8c564b', | ||
| '#e377c2', | ||
| '#7f7f7f', | ||
| '#17becf'] | ||
| i_color = 0 | ||
| plot_colors = ['#000000', '#bc2122', '#55679e', '#69b628', '#dacf2f', '#ff6600'] | ||
| def set_latex_mpl_format(font_size = 15): | ||
| def set_latex_mpl_format(): | ||
| plt.rcParams["font.family"] = "Times New Roman" | ||
| plt.rcParams["font.size"] = font_size | ||
| plt.rcParams["font.size"] = 15 | ||
| # To have math like LaTeX | ||
| plt.rcParams['mathtext.fontset'] = 'cm' | ||
| plt.rcParams['mathtext.rm'] = 'serif' | ||
| # To save svg fonts as fonts and not paths | ||
| plt.rcParams['svg.fonttype'] = 'none' | ||
| def get_color(): | ||
| global i_color | ||
| color = plot_colors[i_color] if i_color < len(plot_colors) else np.random.rand(3) | ||
| i_color += 1 | ||
| return color |
@@ -12,4 +12,3 @@ | ||
| def __setitem__(self, key, value): | ||
| old_value = self.items.get(key, None) | ||
| if old_value: | ||
| if old_value := self.items.get(key, None): | ||
| old_value.parents.remove(self) | ||
@@ -19,3 +18,3 @@ value.name = str(key) | ||
| value.parents.add(self) | ||
| self.notify_graph_change('Notification from child %s' % 'item') | ||
| self.notify_graph_change('Notification from child item') | ||
@@ -26,3 +25,3 @@ def __delitem__(self, key): | ||
| del self.items[key] | ||
| self.notify_graph_change('Notification from child %s' % 'item') | ||
| self.notify_graph_change('Notification from child item') | ||
@@ -29,0 +28,0 @@ def __getitem__(self, key): |
@@ -0,0 +0,0 @@ |
@@ -25,5 +25,3 @@ | ||
| value = getattr(self, name, None) | ||
| # print('name', name, self.__class__, trait_type, value) | ||
| post_setattr = getattr(trait_type, 'post_setattr', None) | ||
| if post_setattr: | ||
| if post_setattr := getattr(trait_type, 'post_setattr', None): | ||
| post_setattr(self, name, value) | ||
@@ -44,3 +42,3 @@ # trait_type.post_setattr(self, name, value) | ||
| _state_change_debug = tr.Bool(False) | ||
| x_state_change_debug = tr.Bool(False) | ||
@@ -50,3 +48,3 @@ state_change_debug = tr.Property(tr.Bool) | ||
| def _get_state_change_debug(self): | ||
| if self._state_change_debug == True: | ||
| if self.x_state_change_debug == True: | ||
| return True | ||
@@ -58,4 +56,15 @@ for parent in self.parents: | ||
| def _set_state_change_debug(self, value=True): | ||
| self._state_change_debug = value | ||
| self.x_state_change_debug = value | ||
| # def __getstate__(self): | ||
| # """Customized getstate for correct serialization.""" | ||
| # state = super().__getstate__() | ||
| # # Include private attributes explicitly | ||
| # return state, self.x_state_change_debug | ||
| # def __setstate__(self, state): | ||
| # """Customized setstate for correct deserialization.""" | ||
| # base_state, self.x_state_change_debug = state | ||
| # super().__setstate__(base_state) | ||
| @tr.observe('+TIME,+MESH,+MAT,+CS,+BC,+ALG,+FE,+DSC,+GEO,+ITR') | ||
@@ -97,3 +106,3 @@ def notify_value_change(self, event): | ||
| if parent: # ignore if parent is garbage collected | ||
| parent.notify_graph_change('Notification from child %s' % self) | ||
| parent.notify_graph_change(f'Notification from child {self}') | ||
@@ -103,3 +112,3 @@ def notify_parents_value_changed(self): | ||
| if parent: # ignore if parent is garbage collected | ||
| parent.notify_value_change('Notification from child %s' % self) | ||
| parent.notify_value_change(f'Notification from child {self}') | ||
@@ -106,0 +115,0 @@ def __del__(self): |
@@ -24,2 +24,4 @@ | ||
| trait = self.trait(name) | ||
| if trait is None: | ||
| raise TypeError(f'trait with {name} not defined in {self}') | ||
| trait_type = trait.trait_type | ||
@@ -29,3 +31,3 @@ name_ = trait_type.get_name_(name) | ||
| if trait_ is None: | ||
| raise ValueError('trait %s not found in %s' % (name_, self)) | ||
| raise ValueError(f'trait {name_} not found in {self}') | ||
| submodels.append(trait_) | ||
@@ -32,0 +34,0 @@ return submodels |
@@ -34,3 +34,3 @@ | ||
| else: | ||
| raise NameError(self.plot_backend + ' is not a valid plot_backend!') | ||
| raise NameError(f'{self.plot_backend} is not a valid plot_backend!') | ||
@@ -37,0 +37,0 @@ def plot(self, axes): |
@@ -0,0 +0,0 @@ ''' |
@@ -0,0 +0,0 @@ import numpy as np |
@@ -0,0 +0,0 @@ import sympy as sp |
+19
-17
@@ -39,7 +39,11 @@ ''' | ||
| # expression reduction for lambdify | ||
| cse = tr.Bool(False) | ||
| # @todo [RC]: check if the model can be taken from the reference | ||
| def get_model_params(self): | ||
| return tuple([ | ||
| getattr(self.model,param_name) for param_name in self.symb_model_params | ||
| ]) | ||
| return tuple( | ||
| getattr(self.model, param_name) | ||
| for param_name in self.symb_model_params | ||
| ) | ||
@@ -49,7 +53,9 @@ def __init__(self, *args, **kw): | ||
| # gather the symbols and construct an ordered tuple | ||
| default_symbols = tuple([getattr(self, sym_name) for sym_name in self.symb_variables]) | ||
| default_symbols = tuple( | ||
| getattr(self, sym_name) for sym_name in self.symb_variables | ||
| ) | ||
| for expression in self.symb_expressions: | ||
| if isinstance(expression, Iterable): | ||
| expr_name, sym_names = expression | ||
| symbols = tuple([getattr(self, sym_name) for sym_name in sym_names]) | ||
| symbols = tuple(getattr(self, sym_name) for sym_name in sym_names) | ||
| elif isinstance(expression, str): | ||
@@ -62,8 +68,10 @@ expr_name = expression | ||
| ) | ||
| param_symbols = tuple([getattr(self, model_param) | ||
| for model_param in self.symb_model_params]) | ||
| param_symbols = tuple( | ||
| getattr(self, model_param) | ||
| for model_param in self.symb_model_params | ||
| ) | ||
| expr = getattr(self, expr_name) | ||
| # print('defining', expr_name, ':', symbols+param_symbols) | ||
| callable = sp.lambdify(symbols+param_symbols, expr, 'numpy') | ||
| # callable = sp.lambdify(symbols, expr, 'numpy', dummify=True) | ||
| callable = sp.lambdify(symbols+param_symbols, expr, 'numpy', | ||
| cse=self.cse) | ||
| def define_callable(callable): | ||
@@ -79,7 +87,5 @@ def on_the_fly(*args): | ||
| return on_the_fly | ||
| self.add_trait( | ||
| 'get_' + expr_name, tr.Callable(define_callable(callable)) | ||
| # lambda *args: callable(*(args+self.get_model_params(self.model))) | ||
| ) | ||
| self.add_trait(f'get_{expr_name}', tr.Callable(define_callable(callable))) | ||
| class InjectSymbExpr(tr.HasStrictTraits): | ||
@@ -97,5 +103,1 @@ ''' | ||
| self.symb = self.symb_class(model = self) | ||
| # def traits_init(self): | ||
| # self.symb = self.symb_class(model = self) | ||
| # |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ #------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ #------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ # ------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ #------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ #------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ # ------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ import traits.api as tr |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ |
@@ -1,1 +0,1 @@ | ||
| __version__='0.0.32a1' | ||
| __version__='0.0.35a' |
@@ -0,0 +0,0 @@ |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: bmcs_utils | ||
| Version: 0.0.32a1 | ||
| Version: 0.0.35a0 | ||
| 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 |
+0
-0
@@ -0,0 +0,0 @@ |
+0
-0
@@ -0,0 +0,0 @@ [egg_info] |
+0
-0
@@ -0,0 +0,0 @@ #!/usr/bin/env python |
-45
| MANIFEST | ||
| build | ||
| dist | ||
| _build | ||
| docs/man/*.gz | ||
| docs/source/api/generated | ||
| docs/source/config.rst | ||
| docs/gh-pages | ||
| notebook/i18n/*/LC_MESSAGES/*.mo | ||
| notebook/i18n/*/LC_MESSAGES/nbjs.json | ||
| notebook/static/components | ||
| notebook/static/style/*.min.css* | ||
| notebook/static/*/js/built/ | ||
| notebook/static/*/built/ | ||
| notebook/static/built/ | ||
| notebook/static/*/js/main.min.js* | ||
| notebook/static/lab/*bundle.js | ||
| node_modules | ||
| *.py[co] | ||
| __pycache__ | ||
| *.egg-info | ||
| *~ | ||
| *.bak | ||
| .ipynb_checkpoints | ||
| .tox | ||
| .DS_Store | ||
| \#*# | ||
| .#* | ||
| .coverage | ||
| .pytest_cache | ||
| src | ||
| *.swp | ||
| *.map | ||
| .idea/ | ||
| Read the Docs | ||
| config.rst | ||
| *.iml | ||
| /.project | ||
| /.pydevproject | ||
| package-lock.json | ||
| geckodriver.log | ||
| *.iml | ||
| name: bmcs_env | ||
| channels: | ||
| - conda-forge | ||
| dependencies: | ||
| - jupyterlab | ||
| - traits>=6.1.1 | ||
| - traitsui==7.1.0 | ||
| - matplotlib-base | ||
| - numpy | ||
| - sympy | ||
| - k3d | ||
| - ipywidgets | ||
| - ipympl | ||
| - ipytree | ||
| - ipyregulartable | ||
| - k3d | ||
| - pip | ||
| - pip: | ||
| - -e ./bmcs_utils | ||
| - -e ./bmcs_ibvpy | ||
| - -e ./bmcs_matmod | ||
| - -e ./bmcs_cross_section | ||
| - -e ./bmcs_shear_zone | ||
| - -e ./bmcs_beam | ||
| - -e ./bmcs_expsim |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
| import numpy as np | ||
| def get_fw_curves_avg(fw_curves_list, ax=None): | ||
| """ | ||
| fw_curves_list: [fw_numpy_array, fw_numpy_array, ...] where fw_numpy_array has the shape (data_length, 2) | ||
| """ | ||
| fw_curves_list = [fw.astype(np.float64) for fw in fw_curves_list] | ||
| w_list = [fw[:, 1] for fw in fw_curves_list] | ||
| f_list = [fw[:, 0] for fw in fw_curves_list] | ||
| max_len = np.max([fw.shape[0] for fw in fw_curves_list]) | ||
| w_max_list = np.array([np.nanmax(w) for w in w_list]) | ||
| w_avg_max = np.average(w_max_list) | ||
| w = np.linspace(0, w_avg_max, max_len) | ||
| w_scaled_list = [w_ * w_avg_max / w_max for w_, w_max in zip(w_list, w_max_list)] | ||
| f_scaled_list = np.array([np.interp(w, w_scaled, f) for w_scaled, f in zip(w_scaled_list, f_list)]) | ||
| f = np.average(f_scaled_list, axis=0) | ||
| if ax is not None: | ||
| ax.plot(w, f, color='gray') | ||
| return f, w | ||
| def get_asc_upper_env_ids(arr): | ||
| """ | ||
| Useful to get the upper envelope of load-displacement curve (representing load-controlled variant) | ||
| arr: one dimentional numpy array (typically with positive elements) | ||
| returns: for example, given the array [2, 1, 0, -5, 5, 3, 9, 10], the ids of [2, 5, 9, 10] will be returned | ||
| """ | ||
| max_ = arr[0] | ||
| upper_env_ids = [0] | ||
| for i, value in enumerate(arr): | ||
| if value > max_: | ||
| max_ = value | ||
| upper_env_ids.append(i) | ||
| return np.array(upper_env_ids) | ||
| def get_exp_fw_asc(fw): | ||
| f_upper_env_ids = get_asc_upper_env_ids(fw[0]) | ||
| return fw[0][f_upper_env_ids].astype(np.float_), fw[1][f_upper_env_ids].astype(np.float_) |
| # Distribution management | ||
| To be able to release versions and to upload | ||
| to the pypi and conda repositories | ||
| following packages are required | ||
| - twine - to upload to pypi | ||
| ``` | ||
| conda install -c conda-forge twine | ||
| ``` | ||
| - conda-build - to provide tha package on the conda repository | ||
| - anaconda-client - to be able to upload the package to anaconda cloud | ||
| # Uploading and releasing your package | ||
| @todo: this requires an access to the pypi | ||
| account - a bmcs-group pypi account needs to be setup. | ||
| # Installation of a pypi package in your environment | ||
| Released package can be installed in the | ||
| current environment. using the command | ||
| ``` | ||
| pip install my_bmcs_package | ||
| ``` | ||
| The old package will be uninstalled | ||
| from the environment and replaced by the released package. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
| # Jupyter interface / Researcher's perspective | ||
| ## Install miniconda | ||
| The packages used in the development of the BMCS tool | ||
| suite can be conveniently accessed from within the | ||
| miniconda minimal setup. The installation of miniconda for | ||
| all platforms is provided here: | ||
| https://docs.conda.io/en/latest/miniconda.html | ||
| ## Install BMCS packages | ||
| Download the package specification file | ||
| `bmcs_env.yml` | ||
| Run the setup of the environment by issuing | ||
| ``` | ||
| conda env create -f bmcs_env.yml | ||
| ``` | ||
| If you wish to update your environment later you can issue | ||
| ``` | ||
| conda env update -f bmcs_env.yml | ||
| ``` | ||
| ## Activate `bmcs_env` environment | ||
| The list of available environments can be obtained by issuing | ||
| ``` | ||
| conda env list | ||
| ``` | ||
| Activate the new environment using | ||
| ``` | ||
| conda activate bmcs_env | ||
| ``` | ||
| The package(s) specified in the `environment.yml` | ||
| are now installed locally in the `bmcs_env` and | ||
| can be imported if this environment is active. | ||
| This can be checked by starting the `python` interpreter | ||
| with the `bmcs_env` environment active and testing | ||
| ``` | ||
| import bmcs_utils.api as bu | ||
| ``` | ||
| ## Setup and configure Jupyter | ||
| To be able to import them, the runtime configuration in Jupyter and Pycharm | ||
| projects have to be configured with this environment. | ||
| 1) register the newly created `bmcs_env` environment as | ||
| a jupyter kernel y ussuing | ||
| ```shell script | ||
| pytom -m ipykernel install --user --name=bmcs_env | ||
| ``` | ||
| 2) start the jupyter notebook, by issuing | ||
| ```shell script | ||
| jupyter notebook | ||
| ``` | ||
| navigate to | ||
| the menu `Kernel -> Change kernel` and select | ||
| the `bmcs_env` kernel as the active kernel. The | ||
| kernel name will be displaed at the top right corner | ||
| of the notebook | ||
| ## Enable notebook extensions | ||
| It is recommended to use the notebook extensions that | ||
| include useful features. The extensions have | ||
| already been installed using `environment.yml`. | ||
| The particular choice depends on personal preference | ||
| and the context of usage. Recommended extensions | ||
| are: | ||
| - table of contents which is useful for long | ||
| noteboks explaining the model derivation | ||
| - RISE: which can convert the notebook to a slide | ||
| presentation | ||
| - appmode: that converts the notebook to an interactive | ||
| web application | ||
| # Access jupyter notebooks | ||
| It is important to note, that only python files are installed | ||
| in the `bmcs_env` - no jupyter notebooks. Thus, they | ||
| are provided just like `numpy` or `matplotlib` for | ||
| further use in the development of further packages. | ||
| In this way, the deployment of the webapps | ||
| on jupyterhub or binder is solved - since it is possible | ||
| to define the environment which automatically | ||
| installed all the required packages on demand | ||
| from the global conda and pypi repos. | ||
| Packaging of jupyter notebooks is a separate problem. | ||
| We use them for several different purposes: | ||
| - prototyping code (Phase 1) | ||
| - verification code for python modules - that's what (Phase 2) | ||
| - documentation with interactive examples (Phase 3) | ||
| - presentations - RISE package (Phase 3) | ||
| - webapps - appmode (Phase 3) | ||
| Thus, in Phases 1 and 2 the notebooks are | ||
| within the development directory. The phase 3 | ||
| is the dissemination of the implemented functionality | ||
| in three different ways. | ||
| ## Plotting using matplotlib | ||
| Matplotlib provides a front end that can be | ||
| combined with the `ipywidgets` to integrate the | ||
| figures within a layout of widgets. To use this | ||
| feature, the notebook must start with the magic command | ||
| ``` | ||
| %matplotlib widget | ||
| ``` | ||
| This feature is implemented in the `ipympl` package | ||
| which is automatically included in the environment | ||
| after the setup. Further instructions to this package | ||
| are included here: | ||
| https://github.com/matplotlib/ipympl | ||
| ## Version control for jupyter notebooks | ||
| If the jupyter notebooks are pushed to the github | ||
| repository it is necessary to strip out the | ||
| output cells to avoid uneceesary conflicts of | ||
| versions. | ||
| ### How to activate `nbstripout` | ||
| Stripping Jupyter output cells and execution | ||
| count out while pushing to Git | ||
| In Anaconda command prompt execute the following commands | ||
| 1. Install `nbstripout` tool:\ | ||
| `conda install -c conda-forge nbstripout` | ||
| 2. Activate the tool on global Git configuration so it work on all your local repositories using | ||
| * **Windows**\ | ||
| ``` | ||
| mkdir %USERPROFILE%\.config\git | ||
| nbstripout --install --global --attributes=%USERPROFILE%\.config\git\attributes | ||
| ``` | ||
| * **Linux**\ | ||
| ``` | ||
| mkdir -p ~/.config/git | ||
| nbstripout --install --global --attributes=~/.config/git/attributes | ||
| ``` | ||
| Now, when you **push** a Jupyter Notebook file, | ||
| the `nbstripout` tool will tell Git to ignore | ||
| the output cells and the execution count numbers, leaving your local Jupyter file unchanged. It will enable you to push a clean Jupyter file to the repository. | ||
| ### How does `nbstripout` work? | ||
| The tool adds a Git filter to these files\ | ||
| `USER_HOME_DIRECTORY\.config\git\attributes`\ | ||
| `USER_HOME_DIRECTORY\.gitconfig`\ | ||
| which strips output cells and execution count out for Jupyter files. | ||
| For more info: https://github.com/kynan/nbstripout |
| # Python interface / Developer perspective | ||
| ## Git | ||
| Install the git package. | ||
| For linux use: | ||
| sudo apt-get install git | ||
| For windows use: | ||
| @todo: please add | ||
| ## PyCharm | ||
| register and pickup the professional academic free version | ||
| https://www.jetbrains.com/pycharm/download | ||
| Follow the instructions there to install it. | ||
| ## Clone bmcs repositories | ||
| Start pycharm. In the introductory window select | ||
| - open from version control system. Register using the github.com | ||
| credentials. Clone the repository | ||
| bmcs-group/bmcs_utils | ||
| ## Setup the development package | ||
| Each of the `bmcs` packages contains the | ||
| `environment.yml` and the `setup.py` file | ||
| in its root directory | ||
| By issuing the command | ||
| ``` | ||
| pip install -e . | ||
| ``` | ||
| your local source code package directory will | ||
| be integrated into the `bmcs_env` | ||
| environment. | ||
| Check to see that it is the case by issuing | ||
| ``` | ||
| import sys | ||
| print(sys.path) | ||
| ``` | ||
| The current package directory should be included in the list. | ||
| This approach has the advantage that your workspace is | ||
| treated in the same way as packages comming from pypi | ||
| repository. This makes the import paths universally | ||
| valid in differnt usage modes: | ||
| [Research access](jupyter_access.md), | ||
| [Python access](python_access.md). | ||
| Moreover, it is used also in the deployed | ||
| installation on a remote service like | ||
| binder launched from the `github` repository. | ||
| This can be seen in the `environment.yml` which | ||
| specifies the required | ||
| packages. Note the last entry in this dependency: | ||
| specifying `-e .` | ||
| ``` | ||
| name: bmcs_env | ||
| channels: | ||
| - conda-forge | ||
| dependencies: | ||
| # required conda packages | ||
| - pip: | ||
| - -e . | ||
| ``` | ||
| The entry `-e .` means that | ||
| The `environment.yml` specification is | ||
| used if the repository is installed in remote services, | ||
| e.g. on `binder`. | ||
| # Configure Jupyter | ||
| To use and modify the jupyter notebooks in your installation | ||
| access setup the jupyter environment as described in | ||
| [Jupyter access](jupyter_access.md) | ||
| # Configure Pycharm | ||
| - In PyCharm - the correct interpreter from `bmcs_env` must be taken - | ||
| in File->Settings->Build->Interpreter | ||
| # Lifecycle of a package | ||
| In case of development installation, the import | ||
| path must be set within the current conda environment. | ||
| In case of application installation, the pip dependency | ||
| management is used to install the required | ||
| packages on demand. | ||
| # BMCS development process | ||
| The BMCS tool suite consists of a packages | ||
| that are developed in parallel. | ||
| The `bmcs_utils` is used by any other package. | ||
| It provides the following functionality: | ||
| - Infrastructure for the definition and composition | ||
| of model components to quickly obtain an interactive | ||
| jupyter user interface. | ||
| - Systematic mapping from symbolic expressions | ||
| derived during the model construction using `sympy` | ||
| to model classes. | ||
| - Infrastructure for persistent data management in | ||
| the `db_cache` directory. | ||
| By using the `bmcs_utils` as the platform for the model | ||
| implementation, the BMCS model components provide | ||
| a transparent mapping between their interactive features | ||
| as they appear in the user interface and their internal | ||
| structure, implementation and theoretical background. | ||
| The developed models are accessible in three perspectives. | ||
| The aim is to provide a seamless transition between the | ||
| individual perspectives to the code. The first perspective | ||
| provides a simple interaction with the model | ||
| via the webapp interface. It presents the functionality and | ||
| features of the model to a (Visitor/Reader/User). | ||
| Deeper explanation of the model features in presented in | ||
| form of jupyter notebooks accompanying every | ||
| model component. These notebooks demonstrate the model | ||
| functionality and can be modfied and extended by the | ||
| user to get deeper insight into the model behavior, into the | ||
| modeled phenomena. Then, they can be used to interpret | ||
| expermental data and to perform parameteric studies. | ||
| To develop own model components the open source code can be | ||
| cloned using the git versioning control system. The repositories | ||
| are available on `github` in the organization | ||
| named `bmcs-group`. | ||
| # Summary of interfaces and roles: | ||
| - [**Webapp interface (student/reader):**](webapp_access.md) via web browser by accessing a remote server. | ||
| either in a `jupyterhub` or using `binder` service. This | ||
| mode is inteded for casual readers and student classes | ||
| that do not need to install anything on their local computer | ||
| and can directly start to interact with the models via | ||
| remote webapps. | ||
| - [**Jupyter interface (researcher)**](jupyter_access.md) To perform intensive studies of the models, | ||
| model calibrations based on experimental data and | ||
| parametric studies the BMCS packages can be installed locally. Included Jupyter notebooks provide the starting | ||
| point for modifications and processing of data. | ||
| - [**Python interface (developer)**](python_access.md) Development of Python code supporting the | ||
| Jupyter notebooks requires the developer setup with an access | ||
| to the `github server` and a development environment. Currently | ||
| `Pycharm` IDE is being used in the development | ||
| of BMCS tool suite. | ||
| - [**Packaging interface (administrator)**](distribution.md) | ||
| Build and upload packages to repositories | ||
| (pypi, conda) |
| # Introduce dependencies between state variables | ||
| Assume two model components defined as follows | ||
| ```python | ||
| import bmcs_utils.api as bu | ||
| import traits.api as tr | ||
| class M1(bu.Model): | ||
| length = bu.Float(10, GEO=True) | ||
| class M2(bu.Model): | ||
| m1 = tr.Instance(M1, ()) | ||
| a = tr.Property(depends_on='+GEO') | ||
| @tr.cached_property | ||
| def _get_a(self): | ||
| return self.m1.length ** 2 | ||
| ``` | ||
| to ensure a consistent state of the model | ||
| in a running application model traits are | ||
| categorized using the tags specifying | ||
| the kind of information that the model parameter | ||
| delivers. Following tags are predefined | ||
| ``` | ||
| GEO, BC, DSC, ALG, INT, TIME | ||
| ``` | ||
| When defining derived properties of the model | ||
| components, these tags are used to handle | ||
| the changes upwards in the hierarchy. | ||
| The model tree structure is extracted by | ||
| traversing the base classes. Each subclass | ||
| of `InteractiveModel` contains the events | ||
| `_TAG` which can be included in the local | ||
| definition of properties and observers | ||
| in the local class definition. |
| # Webapp interface / Browser perspective | ||
| - bmcs |
| name: bmcs_env | ||
| channels: | ||
| - conda-forge | ||
| dependencies: | ||
| - appmode | ||
| - jupyter_contrib_nbextensions | ||
| - traits>=6.1.1 | ||
| - matplotlib-base==3.4.3 | ||
| - numpy | ||
| - sympy | ||
| - k3d | ||
| - ipywidgets==7.6.6 | ||
| - ipympl==0.9.2 | ||
| - ipytree==0.2.2 | ||
| - ipyregulartable | ||
| - pip | ||
| - pip: | ||
| - -e . |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
-38
| {% set name = "bmcs_utils" %} | ||
| {% set version = "0.0.15a0" %} | ||
| package: | ||
| name: "{{ name|lower }}" | ||
| version: "{{ version }}" | ||
| source: | ||
| url: "https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz" | ||
| sha256: 0b3d050b0f040d22c43a0dec5a617f8631b858ed4a6a4122b48cd3e77a6837f5 | ||
| build: | ||
| number: 0 | ||
| script: "{{ PYTHON }} -m pip install . -vv" | ||
| requirements: | ||
| host: | ||
| - pip | ||
| - python | ||
| run: | ||
| - python | ||
| test: | ||
| imports: | ||
| - bmcs_utils | ||
| about: | ||
| home: "https://github.com/bmcs-group/bmcs_utils" | ||
| license: MIT | ||
| license_family: MIT | ||
| license_file: | ||
| summary: "Suite of utilities for to implementation of bmcs_utils for brittle-matrix composites." | ||
| doc_url: | ||
| dev_url: | ||
| extra: | ||
| recipe-maintainers: | ||
| - your-github-id-here |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
120548
-89.1%62
-42.06%2876
-1.64%