Exemple #1
0
 def compute_dr_wrt(self, obj):
     if obj is self.a:
         if not hasattr(self, "_dr_cached"):
             IS = np.arange(len(self.idxs)).flatten()
             JS = self.idxs.ravel()
             ij = np.vstack((row(IS), row(JS)))
             data = np.ones(len(self.idxs))
             self._dr_cached = sp.csc_matrix((data, ij), shape=(len(self.idxs), len(self.a.r.ravel())))
         return self._dr_cached
Exemple #2
0
 def compute_dr_wrt(self, obj):
     if obj is self.a:
         if not hasattr(self, '_dr_cached'):
             IS = np.arange(len(self.idxs)).flatten()
             JS = self.idxs.ravel()
             ij = np.vstack((row(IS), row(JS)))
             data = np.ones(len(self.idxs))
             self._dr_cached = sp.csc_matrix((data, ij), shape=(len(self.idxs), len(self.a.r.ravel())))
         return self._dr_cached
Exemple #3
0
def i3conf_theme():
    return lines(
        "# Theme", "font xft:{} 7".format(font),
        row("client.focused", color.main, color.bg, color.main, color.bg),
        row("client.focused_inactive", color.smooth, color.bg, color.fg,
            color.bg),
        row("client.unfocused", color.smooth, color.bg, color.fg, color.bg),
        row("client.urgent", color.smooth, color.bg, color.fg, color.alert),
        row("client.placeholder", color.smooth, color.bg, color.fg, color.bg),
        "new_window pixel 1", "new_float  pixel 1"
        "")
Exemple #4
0
    def compute_dr_wrt(self, wrt):
        if wrt is self.x:
            if visualize:
                import matplotlib.pyplot as plt
                residuals = np.sum(self.r**2)
                print('------> RESIDUALS %.2e' % (residuals,))
                print('------> CURRENT GUESS %s' % (str(self.x.r),))
                plt.figure(123)

                if not hasattr(self, 'vs'):
                    self.vs = []
                    self.xs = []
                    self.ys = []
                self.vs.append(residuals)
                self.xs.append(self.x.r[0])
                self.ys.append(self.x.r[1])
                plt.clf();
                plt.subplot(1,2,1)
                plt.plot(self.vs)
                plt.subplot(1,2,2)
                plt.plot(self.xs, self.ys)
                plt.draw()


            return row(rosen_der(self.x.r))
Exemple #5
0
    def compute_dr_wrt(self, wrt):
        if wrt is self.x:
            if visualize:
                import matplotlib.pyplot as plt
                residuals = np.sum(self.r**2)
                print '------> RESIDUALS %.2e' % (residuals,)
                print '------> CURRENT GUESS %s' % (str(self.x.r),)
                plt.figure(123)
                
                if not hasattr(self, 'vs'):
                    self.vs = []
                    self.xs = []
                    self.ys = []
                self.vs.append(residuals)
                self.xs.append(self.x.r[0])
                self.ys.append(self.x.r[1])
                plt.clf();
                plt.subplot(1,2,1)
                plt.plot(self.vs)
                plt.subplot(1,2,2)
                plt.plot(self.xs, self.ys)
                plt.draw()


            return row(rosen_der(self.x.r))
Exemple #6
0
def i3conf_theme():
    return lines("# Theme",
                 "font xft:{} 7".format(font),
                 row("client.focused",
                     color.main, color.bg, color.main, color.bg),
                 row("client.focused_inactive",
                     color.smooth, color.bg, color.fg, color.bg),
                 row("client.unfocused",
                     color.smooth, color.bg, color.fg, color.bg),
                 row("client.urgent",
                     color.smooth, color.bg, color.fg, color.alert),
                 row("client.placeholder",
                     color.smooth, color.bg, color.fg, color.bg),

                 "new_window pixel 1",
                 "new_float  pixel 1"
                 "")
Exemple #7
0
def generate_bash():
    bash("menu",
         row("dmenu -b",
             "-p", quotes("$1"),
             "-fn {}-9".format(font),
             "-nb", quotes(color.bg),
             "-nf", quotes(color.fg),
             "-sb", quotes(color.bg),
             "-sf", quotes(color.main)))

    bash("lsws",
         "i3-msg -t get_workspaces |",
         "tr , '\n' |",
         "grep name |",
         "cut -d \\\" -f 4")

    bash("lock",
         "killall -SIGUSR1 dunst",
         "i3lock -n -e -f -d -I 5 -c 111111",
         "killall -SIGUSR2 dunst",
         "xset -dpms")

    bash("sprunga",
         "URL=$(cat $1 | curl -F 'sprunge=<-' http://sprunge.us 2> /dev/null)",
         "echo $URL")

    bash("double-screen",
         row("xrandr",
             "--output LVDS1 --primary --mode 1366x768",
             "--pos 0x0 --rotate normal",
             "--output VGA1 --mode 1024x768 --pos 1366x0 --rotate normal",
             "--output HDMI1 --off"))

    bash("single-screen",
         row("xrandr",
             "--output LVDS1 --primary --mode 1366x768",
             "--pos 0x0 --rotate normal",
             "--output VGA1 --off"))

    bash("stacca",
         "single-screen",
         "lock &",
         "systemctl suspend")

    bash("geolocalize",
         "curl http://ip-api.com/line")
Exemple #8
0
    def compute_d1(self):
        # To stay consistent with numpy, we must upgrade 1D arrays to 2D
        ar = row(self.a.r) if len(self.a.r.shape)<2 else self.a.r.reshape((-1, self.a.r.shape[-1]))
        br = col(self.b.r) if len(self.b.r.shape)<2 else self.b.r.reshape((self.b.r.shape[0], -1))

        if ar.ndim <= 2:
            return sp.kron(sp.eye(ar.shape[0], ar.shape[0]),br.T)
        else:
            raise NotImplementedError
Exemple #9
0
    def compute_d1(self):
        # To stay consistent with numpy, we must upgrade 1D arrays to 2D
        ar = row(self.a.r) if len(self.a.r.shape) < 2 else self.a.r.reshape(
            (-1, self.a.r.shape[-1]))
        br = col(self.b.r) if len(self.b.r.shape) < 2 else self.b.r.reshape(
            (self.b.r.shape[0], -1))

        if ar.ndim <= 2:
            return sp.kron(sp.eye(ar.shape[0], ar.shape[0]), br.T)
        else:
            raise NotImplementedError
Exemple #10
0
    def compute_d2(self):
        
        # To stay consistent with numpy, we must upgrade 1D arrays to 2D
        ar = row(self.a.r) if len(self.a.r.shape)<2 else self.a.r
        br = col(self.b.r) if len(self.b.r.shape)<2 else self.b.r

        if br.ndim <= 1:
            return self.ar
        elif br.ndim <= 2:
            return sp.kron(ar, sp.eye(br.shape[1],br.shape[1]))
        else:
            raise NotImplementedError
Exemple #11
0
 def compute_dr_wrt(self, wrt):
     if wrt is not self.a:
         return None
     
     if self.axis is not None:
         raise NotImplementedError
         
     IS = np.tile(row(np.arange(self.a.size)), (self.a.size, 1))
     JS = IS.T
     IS = IS.ravel()
     JS = JS.ravel()
     which = IS >= JS
     IS = IS[which]
     JS = JS[which]
     data = np.ones_like(IS)
     result = sp.csc_matrix((data, (IS, JS)), shape=(self.a.size, self.a.size))
     return result
Exemple #12
0
    def compute_dr_wrt(self, wrt):
        if wrt is not self.a:
            return None

        if self.axis is not None:
            raise NotImplementedError

        IS = np.tile(row(np.arange(self.a.size)), (self.a.size, 1))
        JS = IS.T
        IS = IS.ravel()
        JS = JS.ravel()
        which = IS >= JS
        IS = IS[which]
        JS = JS[which]
        data = np.ones_like(IS)
        result = sp.csc_matrix((data, (IS, JS)),
                               shape=(self.a.size, self.a.size))
        return result
Exemple #13
0
 def compute_dr_wrt(self, wrt):
     if wrt is not self.x:
         return
     if self.axis == None:
         return row(np.ones((1, len(self.x.r))))/len(self.x.r)
     else:
         uid = tuple(list(self.x.shape) + [self.axis])
         if uid not in self.dr_cache:
             idxs_presum = np.arange(self.x.size).reshape(self.x.shape)
             idxs_presum = np.rollaxis(idxs_presum, self.axis, 0)
             idxs_postsum = np.arange(self.r.size).reshape(self.r.shape)
             tp = np.ones(idxs_presum.ndim)
             tp[0] = idxs_presum.shape[0]
             idxs_postsum = np.tile(idxs_postsum, tp)
             data = np.ones(idxs_postsum.size) / self.x.shape[self.axis]
             result = sp.csc_matrix((data, (idxs_postsum.ravel(), idxs_presum.ravel())), (self.r.size, wrt.size))
             self.dr_cache[uid] = result
         return self.dr_cache[uid]
Exemple #14
0
 def compute_dr_wrt(self, wrt):
     if wrt is not self.x:
         return
     if self.axis == None:
         return row(np.ones((1, len(self.x.r)))) / len(self.x.r)
     else:
         uid = tuple(list(self.x.shape) + [self.axis])
         if uid not in self.dr_cache:
             idxs_presum = np.arange(self.x.size).reshape(self.x.shape)
             idxs_presum = np.rollaxis(idxs_presum, self.axis, 0)
             idxs_postsum = np.arange(self.r.size).reshape(self.r.shape)
             tp = np.ones(idxs_presum.ndim, dtype=np.uint32)
             tp[0] = idxs_presum.shape[0]
             idxs_postsum = np.tile(idxs_postsum, tp)
             data = np.ones(idxs_postsum.size) / self.x.shape[self.axis]
             result = sp.csc_matrix(
                 (data, (idxs_postsum.ravel(), idxs_presum.ravel())),
                 (self.r.size, wrt.size))
             self.dr_cache[uid] = result
         return self.dr_cache[uid]
Exemple #15
0
 def compute_dr_wrt(self, wrt):
     if wrt is self.x:
         return row(self.x.r.ravel() * 2.)
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

server = app.server

colors = {
    'background': 'white',
    'text': 'blue'
}

app.layout = html.Div(
    children=[
        row([
            html.H2(
                'Visualizing common distributions',
                style={ 'textAlign': 'center', 'color': colors['text']},
        )]),

        row([
            column([
                row([
                    html.Br(),
                    html.Label('Set N:'),
                    dcc.Input(id='set_n', value=10, type='number', min=0, step=1, size=1),
                ]),
                row([
                    html.Label('Set p:'),
                    dcc.Input(id='set_p', value=0.5, type='number', min=0.0, max=1.0, step=0.05),
                ])
            ], className='two columns'),
Exemple #17
0
def generate_i3bar():
    write_file(path.i3status,
               i3bar_order("volume master",
                           "wireless wlp3s0",
                           "ethernet enp0s25",
                           "ethernet tun0",
                           "battery 0",
                           "cpu_temperature 0",
                           "cpu_usage 0",
                           "load",
                           "tztime local"),

               i3bar_block("general",
                           "colors", "true",
                           "color_degraded", quotes(color.fg),
                           "color_good", quotes(color.main),
                           "color_bad", quotes(color.alert),
                           "output_format", "i3bar",
                           "interval", "1"),

               i3bar_block("wireless wlp3s0",
                           "format_up", quotes(" %quality %essid %ip"),
                           "format_down", quotes("")),

               i3bar_block("ethernet enp0s25",
                           "format_up", quotes("%ip"),
                           "format_down", quotes("")),

               i3bar_block("ethernet tun0",
                           "format_up", quotes("%ip"),
                           "format_down", quotes("")),

               i3bar_block("battery 0",
                           "format", quotes("%status %percentage %remaining"),
                           "format_down", quotes(""),
                           "last_full_capacity", "true",
                           "integer_battery_capacity", "true",
                           "low_threshold", "11",
                           "threshold_type", "percentage",
                           "hide_seconds", "true",
                           "status_chr", quotes(" "),
                           "status_bat", quotes(""),
                           "status_full", quotes(" ")),

               i3bar_block("tztime local",
                           "format", quotes("%A %e.%B %H:%M:%S")),

               i3bar_block("load",
                           "format", quotes(" %1min")),

               i3bar_block("cpu_usage",
                           "format", quotes(" %usage")),

               i3bar_block("cpu_temperature 0",
                           "format", quotes(" %degrees°C")),

               i3bar_block(row("disk", quotes("/")),
                           "format", quotes("%free")),

               i3bar_block(row("disk", quotes("/home")),
                           "format", quotes(" %free")),

               i3bar_block("volume master",
                           "format", quotes(" %volume"),
                           "format_muted", quotes(" --%%"),
                           "device", quotes("default"),
                           "mixer", quotes("Master"),
                           "mixer_idx", "0"))
Exemple #18
0
def i3conf_bar():
    return lines("# Bar",
                 block("bar",
                       # row("status_command", "i3status"),
                       row("output", "LVDS1"),
                       row("status_command", "i3status"),
                       row("position", "bottom"),
                       "font xft:{} 7".format(font),
                       row("separator_symbol", quotes(" · ")),
                       block("colors",
                             row("background", color.bg),
                             row("statusline", color.fg),
                             row("separator", color.main),
                             row("focused_workspace",
                                 color.main, color.bg, color.main),
                             row("active_workspace",
                                 color.bg, color.bg, "#5f676a"),
                             row("inactive_workspace",
                                 color.bg, color.bg, color.fg),
                             row("urgent_workspace",
                                 color.alert, color.bg, color.alert),
                             "")
                       ),
                 "")
Exemple #19
0
def i3conf_bar():
    return lines(
        "# Bar",
        block(
            "bar",
            # row("status_command", "i3status"),
            row("output", "LVDS1"),
            row("status_command", "i3status"),
            row("position", "bottom"),
            "font xft:{} 7".format(font),
            row("separator_symbol", quotes(" · ")),
            block("colors", row("background", color.bg),
                  row("statusline", color.fg), row("separator", color.main),
                  row("focused_workspace", color.main, color.bg, color.main),
                  row("active_workspace", color.bg, color.bg, "#5f676a"),
                  row("inactive_workspace", color.bg, color.bg, color.fg),
                  row("urgent_workspace", color.alert, color.bg, color.alert),
                  "")),
        "")
Exemple #20
0
 def compute_dr_wrt(self, wrt):
     if wrt is self.x:
         return row(self.x.r.ravel()*2.)
Exemple #21
0
 def compute_dr_wrt(self, wrt):
     if wrt is self.x:
         return row(self.r * np.linalg.inv(self.x.r).T)