Skip to content

Commit

Permalink
add compute_hessian verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Feb 18, 2025
1 parent 91103d6 commit d002b32
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 196 deletions.
4 changes: 3 additions & 1 deletion vedo/applications.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import time
from typing import Union

import numpy as np
Expand Down Expand Up @@ -2409,6 +2408,8 @@ def __init__(self, h=None, m=None, s=None, font="Quikhand", title="", c="k"):
```
![](https://vedo.embl.es/images/feats/clock.png)
"""
import time

self.elapsed = 0
self._start = time.time()

Expand Down Expand Up @@ -2454,6 +2455,7 @@ def __init__(self, h=None, m=None, s=None, font="Quikhand", title="", c="k"):

def update(self, h=None, m=None, s=None) -> "Clock":
"""Update clock with current or user time."""
import time
parts = self.unpack()
self.elapsed = time.time() - self._start

Expand Down
224 changes: 53 additions & 171 deletions vedo/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import os
import sys
import time
from time import time, ctime

import numpy as np
import vedo.vtkclasses as vtki
Expand All @@ -26,7 +26,7 @@
"build_lut",
]


#########################################################
try:
import matplotlib
try:
Expand All @@ -41,6 +41,9 @@
# see below, this is dealt with in color_map()
# print("colors.py: _has_matplotlib", _has_matplotlib)

_printc_delay_timestamp = [0]


#########################################################
# handy global shortcuts for terminal printing
# Ex.: print(colors.red + "hello" + colors.reset)
Expand Down Expand Up @@ -165,7 +168,7 @@
"bisque": "#FFE4C4",
"black": "#000000",
"blanchedalmond": "#FFEBCD",
"blue": "#0f00fb", # "0000FF",
"blue": "#0f00fb",
"blueviolet": "#8A2BE2",
"brown": "#A52A2A",
"burlywood": "#DEB887",
Expand Down Expand Up @@ -207,7 +210,7 @@
"gold": "#FFD700",
"goldenrod": "#DAA520",
"gray": "#808080",
"green": "#047f10", # "#008000",
"green": "#047f10",
"greenyellow": "#ADFF2F",
"honeydew": "#F0FFF0",
"hotpink": "#FF69B4",
Expand Down Expand Up @@ -409,171 +412,39 @@


# available colormap names:
cmaps_names = (
"Accent",
"Accent_r",
"Blues",
"Blues_r",
"BrBG",
"BrBG_r",
"BuGn",
"BuGn_r",
"BuPu",
"BuPu_r",
"CMRmap",
"CMRmap_r",
"Dark2",
"Dark2_r",
"GnBu",
"GnBu_r",
"Greens",
"Greens_r",
"Greys",
"Greys_r",
"OrRd",
"OrRd_r",
"Oranges",
"Oranges_r",
"PRGn",
"PRGn_r",
"Paired",
"Paired_r",
"Pastel1",
"Pastel1_r",
"Pastel2",
"Pastel2_r",
"PiYG",
"PiYG_r",
"PuBu",
"PuBuGn",
"PuBuGn_r",
"PuBu_r",
"PuOr",
"PuOr_r",
"PuRd",
"PuRd_r",
"Purples",
"Purples_r",
"RdBu",
"RdBu_r",
"RdGy",
"RdGy_r",
"RdPu",
"RdPu_r",
"RdYlBu",
"RdYlBu_r",
"RdYlGn",
"RdYlGn_r",
"Reds",
"Reds_r",
"Set1",
"Set1_r",
"Set2",
"Set2_r",
"Set3",
"Set3_r",
"Spectral",
"Spectral_r",
"Wistia",
"Wistia_r",
"YlGn",
"YlGnBu",
"YlGnBu_r",
"YlGn_r",
"YlOrBr",
"YlOrBr_r",
"YlOrRd",
"YlOrRd_r",
"afmhot",
"afmhot_r",
"autumn",
"autumn_r",
"binary",
"binary_r",
"bone",
"bone_r",
"brg",
"brg_r",
"bwr",
"bwr_r",
"cividis",
"cividis_r",
"cool",
"cool_r",
"coolwarm",
"coolwarm_r",
"copper",
"copper_r",
"cubehelix",
"cubehelix_r",
"flag",
"flag_r",
"gist_earth",
"gist_earth_r",
"gist_gray",
"gist_gray_r",
"gist_heat",
"gist_heat_r",
"gist_ncar",
"gist_ncar_r",
"gist_rainbow",
"gist_rainbow_r",
"gist_stern",
"gist_stern_r",
"gist_yarg",
"gist_yarg_r",
"gnuplot",
"gnuplot2",
"gnuplot2_r",
"gnuplot_r",
"gray_r",
"hot",
"hot_r",
"hsv",
"hsv_r",
"inferno",
"inferno_r",
"jet",
"jet_r",
"magma",
"magma_r",
"nipy_spectral",
"nipy_spectral_r",
"ocean",
"ocean_r",
"pink_r",
"plasma",
"plasma_r",
"prism",
"prism_r",
"rainbow",
"rainbow_r",
"seismic",
"seismic_r",
"spring",
"spring_r",
"summer",
"summer_r",
"tab10",
"tab10_r",
"tab20",
"tab20_r",
"tab20b",
"tab20b_r",
"tab20c",
"tab20c_r",
"terrain",
"terrain_r",
"twilight",
"twilight_r",
"twilight_shifted",
"twilight_shifted_r",
"viridis",
"viridis_r",
"winter",
"winter_r",
)

cmaps_names = [
"Accent", "Accent_r", "Blues", "Blues_r", "BrBG",
"BrBG_r", "BuGn", "BuGn_r", "BuPu", "BuPu_r",
"CMRmap", "CMRmap_r", "Dark2", "Dark2_r", "GnBu",
"GnBu_r", "Greens", "Greens_r", "Greys", "Greys_r",
"OrRd", "OrRd_r", "Oranges", "Oranges_r", "PRGn",
"PRGn_r", "Paired", "Paired_r", "Pastel1", "Pastel1_r",
"Pastel2", "Pastel2_r", "PiYG", "PiYG_r", "PuBu",
"PuBuGn", "PuBuGn_r", "PuBu_r", "PuOr", "PuOr_r",
"PuRd", "PuRd_r", "Purples", "Purples_r", "RdBu",
"RdBu_r", "RdGy", "RdGy_r", "RdPu", "RdPu_r",
"RdYlBu", "RdYlBu_r", "RdYlGn", "RdYlGn_r", "Reds",
"Reds_r", "Set1", "Set1_r", "Set2", "Set2_r",
"Set3", "Set3_r", "Spectral", "Spectral_r", "Wistia",
"Wistia_r", "YlGn", "YlGnBu", "YlGnBu_r", "YlGn_r",
"YlOrBr", "YlOrBr_r", "YlOrRd", "YlOrRd_r", "afmhot",
"afmhot_r", "autumn", "autumn_r", "binary", "binary_r",
"bone", "bone_r", "brg", "brg_r", "bwr", "bwr_r",
"cividis", "cividis_r", "cool", "cool_r", "coolwarm",
"coolwarm_r", "copper", "copper_r", "cubehelix", "cubehelix_r",
"flag", "flag_r", "gist_earth", "gist_earth_r", "gist_gray",
"gist_gray_r", "gist_heat", "gist_heat_r", "gist_ncar", "gist_ncar_r",
"gist_rainbow", "gist_rainbow_r", "gist_stern", "gist_stern_r", "gist_yarg",
"gist_yarg_r", "gnuplot", "gnuplot2", "gnuplot2_r", "gnuplot_r", "gray_r",
"hot", "hot_r", "hsv", "hsv_r", "inferno", "inferno_r",
"jet", "jet_r", "magma", "magma_r", "nipy_spectral", "nipy_spectral_r",
"ocean", "ocean_r", "pink_r", "plasma", "plasma_r", "prism",
"prism_r", "rainbow", "rainbow_r", "seismic", "seismic_r", "spring",
"spring_r", "summer", "summer_r", "tab10", "tab10_r", "tab20",
"tab20_r", "tab20b", "tab20b_r", "tab20c", "tab20c_r", "terrain",
"terrain_r", "twilight", "twilight_r", "twilight_shifted", "twilight_shifted_r",
"viridis", "viridis_r", "winter", "winter_r",
]

# default color palettes when using an index
palettes = (
Expand Down Expand Up @@ -1104,6 +975,7 @@ def printc(
link="",
end="\n",
flush=True,
delay=0,
return_string=False,
):
"""
Expand Down Expand Up @@ -1135,6 +1007,8 @@ def printc(
(must press Ctrl+click to open the link)
flush : (bool)
flush buffer after printing [True]
delay : (float)
print only every `delay` seconds
return_string : (bool)
return the string without printing it [False]
end : (str)
Expand All @@ -1154,12 +1028,19 @@ def printc(
![](https://user-images.githubusercontent.com/32848391/50739010-2bfc2b80-11da-11e9-94de-011e50a86e61.jpg)
"""

if delay:
tm = time()
if tm - _printc_delay_timestamp[0] > delay:
_printc_delay_timestamp[0] = tm
else:
return '' # skip print

if not vedo.settings.enable_print_color or not _terminal_has_colors:
if return_string:
return ''.join(strings)
else:
print(*strings, end=end, flush=flush)
return
return ''

try: # -------------------------------------------------------------

Expand Down Expand Up @@ -1276,6 +1157,7 @@ def printc(

if flush:
sys.stdout.flush()
return ''


def printd(*strings, q=False):
Expand All @@ -1292,7 +1174,7 @@ def printd(*strings, q=False):

fname = os.path.basename(getframeinfo(cf).filename)
print("\x1b[7m\x1b[3m\x1b[37m" + fname + " line:\x1b[1m" + str(cfi.lineno) + reset, end="")
print("\x1b[3m\x1b[37m\x1b[2m", "\U00002501" * 30, time.ctime(), reset)
print("\x1b[3m\x1b[37m\x1b[2m", "\U00002501" * 30, ctime(), reset)
if strings:
print(" \x1b[37m\x1b[1mMessage : ", *strings)
print(" \x1b[37m\x1b[1mFunction:\x1b[0m\x1b[37m " + str(cfi.function))
Expand Down
Loading

0 comments on commit d002b32

Please sign in to comment.