Пример #1
0
def main():
    args = parse_args()

    if args.input:
        lat = load_lattice(args.input)
    else:
        lat = generate_lattice(args.generator, args.generator_args)

    if args.labels:
        labelLat = fileio.read(args.labels)
        if not labelLat.check_consistency():
            print("Label lattice is inconsistent")
            sys.exit(1)
        labels = labelLat.label_graph(args.method)

        if args.plot_labels:
            show_lattice(labelLat, labels)

        lat.relabel(labels)

    if args.plot:
        if args.labels:
            show_lattice(lat, labels)
        else:
            show_lattice(lat, np.arange(len(lat)))

    if args.plot_adjacency:
        show_adjacency_matrix(lat)

    if args.output:
        fileio.write(args.output, lat)

    if args.plot or args.plot_labels or args.plot_adjacency:
        plt.show()
Пример #2
0
def load_lattice(fname):
    lat = fileio.read(fname)
    if not lat.check_consistency():
        print("Input lattice is inconsistent")
        sys.exit(1)
    if not lat.name:
        lat.name = fname
    return lat
Пример #3
0
 def gen(self, filename, f, x0, x1, interp, order, steps, n):
     if filename is None:
         self.xpoints, self.ypoints, self.levels, self.f = None, None, None, None
         try:
             if f[0] == f[-1] == '"' or f[0] == f[-1] == "'":
                 f = f[1:-1]
             self.f = lambdify(x, sympify(f), modules="numpy")
         except:
             raise HandledValueError('Malformed expression')
     else:
         self.f = None
         self.xpoints, self.ypoints, self.levels = fileio.read(filename)
     self.update(x0, x1, interp, order, steps, n)
def get_collisions(infile, verbose=False):

    ev = None

    events = []

    while 1:
        ev = read(infile)

        if ev is None:
            break
        else:
            events.append(ev)

    return events
def get_collisions(infile,verbose=False):

    ev=None

    events = []

    while 1:
        ev = read(infile)

        if ev is None:
            break
        else:
            events.append(ev)

    return events
Пример #6
0
 def load(self, filename):
     self.pcoords = fileio.read(filename)
     self._points = None
     self.loaded = True
     self.conj_pcoords = None
Пример #7
0
#!/usr/bin/env python

from event import Event
from fileio import read

f = open("test.odf", "rb")

ev = read(f)

print ev
Пример #8
0
def get_config_content():
    load_config = fileio.read(configuration.CONFIG_PATH)
    response = make_response(json.dumps({'data': load_config}))
    response.headers["Content-type"] = "application/json"
    return response
Пример #9
0
def battery_status_original():
    m = re.search('(\w+)', fileio.read(status_file))
    if m:
        return m.group(1)
Пример #10
0
def battery_capacity():
    m = re.search('(\d+)', fileio.read(capacity_file))
    if m:
        return _limit(int(m.group(1)), 0, 100)
Пример #11
0
 def load(self, filename):
     self.x, self.y = fileio.read(filename)
     self.xpoints, self.ypoints, self.levels, self.f = None, None, None, None
Пример #12
0
def _read_json(fname):
    text = fileio.read(fname)
    if len(text) > 0:
        return json.loads(text)