15.2.171. camcops_server.cc_modules.cc_trackerhelpers

camcops_server/cc_modules/cc_trackerhelpers.py


Copyright (C) 2012, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).

This file is part of CamCOPS.

CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.


Helper representations for trackers.

class camcops_server.cc_modules.cc_trackerhelpers.LabelAlignment(value)[source]

Enum representing figure label alignment.

class camcops_server.cc_modules.cc_trackerhelpers.TrackerAxisTick(y: float, label: str)[source]

Representation of a Y-axis tick mark and associated label on a camcops_server.cc_modules.cc_tracker.Tracker figure.

__init__(y: float, label: str)[source]
class camcops_server.cc_modules.cc_trackerhelpers.TrackerInfo(value: float, plot_label: Optional[str] = None, axis_label: Optional[str] = None, axis_min: Optional[float] = None, axis_max: Optional[float] = None, axis_ticks: Optional[List[camcops_server.cc_modules.cc_trackerhelpers.TrackerAxisTick]] = None, horizontal_lines: Optional[List[float]] = None, horizontal_labels: Optional[List[camcops_server.cc_modules.cc_trackerhelpers.TrackerLabel]] = None, aspect_ratio: Optional[float] = 2.0)[source]

Tasks return one or more of these (one for each tracker to be shown), from which camcops_server.cc_modules.cc_tracker.Tracker displays are created.

__init__(value: float, plot_label: Optional[str] = None, axis_label: Optional[str] = None, axis_min: Optional[float] = None, axis_max: Optional[float] = None, axis_ticks: Optional[List[camcops_server.cc_modules.cc_trackerhelpers.TrackerAxisTick]] = None, horizontal_lines: Optional[List[float]] = None, horizontal_labels: Optional[List[camcops_server.cc_modules.cc_trackerhelpers.TrackerLabel]] = None, aspect_ratio: Optional[float] = 2.0)[source]
Parameters
  • value – numerical value

  • plot_label – label for the whole plot

  • axis_label – label for the Y axis

  • axis_min – minimum value for the Y axis

  • axis_max – maximum value for the Y axis

  • axis_ticks – optional list of TrackerAxisTick objects describing where to put tick marks/labels on the Y axis

  • horizontal_lines – optional list of y values at which to draw horizontal (dotted) lines

  • horizontal_labels – optional list of TrackerLabel objects indicating which additional labels to place on the main plot (such as: to describe the meaning of the horizontal lines)

  • aspect_ratio – optional aspect ratio (width / height)

class camcops_server.cc_modules.cc_trackerhelpers.TrackerLabel(y: float, label: str, vertical_alignment: camcops_server.cc_modules.cc_trackerhelpers.LabelAlignment = LabelAlignment.center)[source]

Representation of a label on a camcops_server.cc_modules.cc_tracker.Tracker figure.

__init__(y: float, label: str, vertical_alignment: camcops_server.cc_modules.cc_trackerhelpers.LabelAlignment = LabelAlignment.center)[source]
Parameters
  • y – Y axis (vertical) position

  • label – text for label

  • vertical_alignmentLabelAlignment enum

camcops_server.cc_modules.cc_trackerhelpers.equally_spaced_float(start: float, stop: float, num: int, endpoint: bool = True) List[float][source]

Returns a float equivalent of equally_spaced_float() (q.v.).

camcops_server.cc_modules.cc_trackerhelpers.equally_spaced_int(start: int, stop: int, step: int, endpoint: bool = True) List[int][source]

Almost a synonym for range()!

Parameters
  • start – starting value

  • stop – stopping value (INCLUSIVE if endpoint is True)

  • step – step size

  • endpoint – bool

Returns

list of integers

camcops_server.cc_modules.cc_trackerhelpers.equally_spaced_ndarray(start: float, stop: float, num: int, endpoint: bool = True) numpy.ndarray[source]

Produces equally spaced numbers. See https://stackoverflow.com/questions/477486/how-to-use-a-decimal-range-step-value.

Parameters
  • start – starting value

  • stop – stopping value

  • num – number of values to return

  • endpoint – include the endpoint?

Returns

list of floats

camcops_server.cc_modules.cc_trackerhelpers.regular_tracker_axis_ticks_float(start: float, stop: float, num: int, endpoint: bool = True) List[camcops_server.cc_modules.cc_trackerhelpers.TrackerAxisTick][source]
Parameters
  • start – starting value

  • stop – stopping value

  • num – number of values to return

  • endpoint – include the endpoint?

Returns

a list of simple numerical TrackerAxisTick objects

camcops_server.cc_modules.cc_trackerhelpers.regular_tracker_axis_ticks_int(start: int, stop: int, step: int, endpoint: bool = True) List[camcops_server.cc_modules.cc_trackerhelpers.TrackerAxisTick][source]
Parameters
  • start – starting value

  • stop – stopping value

  • step – step size

  • endpoint – include the endpoint?

Returns

a list of simple numerical TrackerAxisTick objects