Skip to content

Commit

Permalink
Merge pull request #270 from Dessia-tech/dev
Browse files Browse the repository at this point in the history
v0.14.0
  • Loading branch information
Tanguylo authored Jun 15, 2023
2 parents 5f8e720 + 1f7f668 commit fef3288
Show file tree
Hide file tree
Showing 29 changed files with 1,650 additions and 1,584 deletions.
6 changes: 3 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ steps:
- npx typedoc

- name: install, run scripts and build doc
image: python:3.8
image: python:3.9
commands:
- git fetch --tags
- python setup.py install
Expand Down Expand Up @@ -97,7 +97,7 @@ steps:
email: root@dessia.tech

- name: check changelog update
image: python:3.8
image: python:3.9
when:
event: pull_request
branch:
Expand Down Expand Up @@ -180,7 +180,7 @@ steps:
- bash code_pep8.sh

- name: sdist
image: python:3.8
image: python:3.9
commands:
- python setup.py sdist

Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.14.0]
### Add
- to_html method in Python so that it is possible to create a plot data file without opening it in web browser
- Allow to draw all points of a Dataset in Graph objects

### Fix
- Smart writing of axes' names in ParallelPlot
- Allow to draw all points of a Dataset in Graph objects
- Python 3.9 in drone
- Remove numpy from dependencies

## [0.13.0]
### Add
- Doc Typescript
Expand Down
20 changes: 9 additions & 11 deletions code_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,36 @@

from pylint.lint import Run

MIN_NOTE = 9.10
MIN_NOTE = 9.50
# RATCHET_NOTE = 0.4
# RATCHET_ERRORS = 3

UNWATCHED_ERRORS = ['fixme', 'trailing-whitespace', 'import-error', 'missing-final-newline', 'trailing-newlines']

MAX_ERROR_BY_TYPE = {
'protected-access': 26,
'invalid-name': 13,
'consider-using-f-string': 2,
'protected-access': 1,
'invalid-name': 6,
'no-else-return': 17,
'arguments-differ': 13,
'arguments-differ': 2,
'no-member': 1,
'too-many-locals': 3,
'too-many-locals': 2,
'wrong-import-order': 1,
'too-many-branches': 1,
'unused-import': 1,
'unused-argument': 4,
'cyclic-import': 11,
'no-self-use': 6,
'unused-variable': 1,
'trailing-whitespace': 11,
'empty-docstring': 7,
'missing-module-docstring': 4,
'too-many-arguments': 15,
'too-few-public-methods': 7,
'too-many-arguments': 16,
'too-few-public-methods': 5,
'unnecessary-comprehension': 5,
'no-value-for-parameter': 2,
'too-many-return-statements': 8,
'raise-missing-from': 6,
'consider-merging-isinstance': 6,
'abstract-method': 25,
'abstract-method': 26,
'import-outside-toplevel': 7,
'too-many-instance-attributes': 3,
'consider-iterating-dictionary': 4,
Expand Down Expand Up @@ -146,7 +144,7 @@ def extract_messages_by_type(type_):


if error_detected:
raise RuntimeError('Too many errors\nRun pylint dessia_common to get the errors')
raise RuntimeError('Too many errors\nRun pylint plot_data to get the errors')

if error_over_ratchet_limit:
raise RuntimeError('Please lower the error limits in code_pylint.py MAX_ERROR_BY_TYPE according to warnings above')
Expand Down
9 changes: 9 additions & 0 deletions cypress/e2e/parallelplot.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { parseHTML } from '../support/parseHTML';
import parallelPlotData from '../data_src/parallelplot.data.json';
import { Interactions } from '../../src/plot-data';

const FEATURE_NAME = "parallelplot"

Expand All @@ -16,4 +17,12 @@ describe('PARALLEL PLOT CANVAS', function () {
it("should draw canvas", function () {
cy.compareSnapshot(describeTitle + this.test.title, 0.05);
})

it("should draw a nice horizontal parallel plot", function () {
cy.window().then((win) => {
let parallelPlot = win.eval('plot_data')
Interactions.change_disposition_action(parallelPlot);
cy.compareSnapshot(describeTitle + this.test.title, 0.05);
})
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion plot_data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pkg_resources
""" Plot data package init. """

import pkg_resources
from .core import *

__version__ = pkg_resources.require("plot_data")[0].version
51 changes: 20 additions & 31 deletions plot_data/colors.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,48 @@

""" Basics and methods for color handling in plot_data. """

import dessia_common.core as dc
from dessia_common.serialization import SerializableObject
from dessia_common.typings import JsonSerializable
from matplotlib.colors import hsv_to_rgb


class Color(dc.DessiaObject):
def __init__(self, red: float, green: float, blue: float):
""" Base class for handling colors as objects. """

def __init__(self, red: float, green: float, blue: float, name: str = ""):
self.red = red
self.green = green
self.blue = blue

self.rgb = (red, green, blue)
dc.DessiaObject.__init__(self, name=name)

@classmethod
def from_hex(cls, hex_code):
"""
:param hex_code: an hexadecimal string
:type hex_code: str
:return: a Color object
:rtype: Color
"""
""" Get REB color from hexadecimal color. """
hex_code = hex_code.replace('#', '')
r, g, b = (int(hex_code[i:i + 2], 16) / 255. for i in (0, 2, 4))
return cls(r, g, b)
red, green, blue = (int(hex_code[i:i + 2], 16) / 255. for i in (0, 2, 4))
return cls(red, green, blue)

@classmethod
def from_hsv(cls, h: float, s: float, v: float):
"""
:return: a Color object
:rtype: Color
"""
red, green, blue = hsv_to_rgb(h, s, v)
def from_hsv(cls, hue: float, saturation: float, value: float):
""" Get RGB color from HSV color. """
red, green, blue = hsv_to_rgb(hue, saturation, value)
return cls(red=red, green=green, blue=blue)

def __str__(self):
"""
:return: a string rgb(r, g, b) in rgb255
"""
return 'rgb({},{},{})'.format(round(self.red * 255),
round(self.green * 255),
round(self.blue * 255))
return f"rgb({round(self.red * 255)},{round(self.green * 255)},{round(self.blue * 255)})"

def to_dict(self, *args, **kwargs):
def to_dict(self, **_) -> JsonSerializable:
""" Get dict of color. """
# TODO: change this!!! it cannot be deserialized in generic way
return str(self)

@classmethod
def dict_to_object(cls, d):
"""
:return: a Color object
"""
if not d.startswith('rgb('):
def dict_to_object(cls, dict_: JsonSerializable, **_) -> SerializableObject:
""" Get color object from dict. """
if not dict_.startswith('rgb('):
raise ValueError('Color should be string starting with rgb(')
return cls(*(int(v) / 255. for v in d[4:-1].split(',')))
return cls(*(int(v) / 255. for v in dict_[4:-1].split(',')))


RED = Color.dict_to_object('rgb(247,0,0)')
Expand Down
Loading

0 comments on commit fef3288

Please sign in to comment.